]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
ACPI: custom_method: fix potential use-after-free issue
authorMark Langsdorf <mlangsdo@redhat.com>
Fri, 23 Apr 2021 15:28:17 +0000 (10:28 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:59:30 +0000 (10:59 +0200)
commit0603973d8065c3501ef09e2ed28ffea04e8862e4
tree7bf5c1ef5ed9c43330f8a10c92f4d8e63d8f5ead
parent062e30b96557ca98cea83226da41606c1b2d2f8f
ACPI: custom_method: fix potential use-after-free issue

BugLink: https://bugs.launchpad.net/bugs/1928825
commit e483bb9a991bdae29a0caa4b3a6d002c968f94aa upstream.

In cm_write(), buf is always freed when reaching the end of the
function.  If the requested count is less than table.length, the
allocated buffer will be freed but subsequent calls to cm_write() will
still try to access it.

Remove the unconditional kfree(buf) at the end of the function and
set the buf to NULL in the -EINVAL error path to match the rest of
function.

Fixes: 03d1571d9513 ("ACPI: custom_method: fix memory leaks")
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/acpi/custom_method.c