]> git.baikalelectronics.ru Git - 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)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 28 Apr 2021 17:17:54 +0000 (19:17 +0200)
commitcf12ed178f58f507baab4f2cb4084af86d0ebf81
treee843fc6d6d26bd778bbe7529ffc0c3e115628f39
parent326939422aeb2d70fd1e9b67c716158a94e017c2
ACPI: custom_method: fix a possible memory leak

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: e4125a4e421a ("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>
drivers/acpi/custom_method.c