]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
ACPI: custom_method: fix a possible memory leak
authorMark Langsdorf <mlangsdo@redhat.com>
Tue, 27 Apr 2021 18:54:33 +0000 (13:54 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:31:50 +0000 (10:31 +0200)
commit87fef6b11978b5b5e7a5b6c44444f3b234294e08
treeef7ff3b95da8940b009f0023aa001d2d62a1912b
parent0f47da071b179c2cdf7fe2849c36efe0bd53ca26
ACPI: custom_method: fix a possible memory leak

BugLink: https://bugs.launchpad.net/bugs/1928857
commit 1cfd8956437f842836e8a066b40d1ec2fc01f13e upstream.

In cm_write(), if the 'buf' is allocated memory but not fully consumed,
it is possible to reallocate the buffer without freeing it by passing
'*ppos' as 0 on a subsequent call.

Add an explicit kfree() before kzalloc() to prevent the possible memory
leak.

Fixes: 526b4af47f44 ("ACPI: Split out custom_method functionality into an own driver")
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