diff options
author | Wenwen Wang <wenwen@cs.uga.edu> | 2019-08-16 00:08:27 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-05 13:13:52 +0200 |
commit | 70424999fbf1f160ade111cb9baab51776e0f9c2 (patch) | |
tree | 964bee9ba89188cdd0e6a5100e69045bb705b81c /drivers/acpi | |
parent | 997c08a494439fa062c851f5d73966f44415b061 (diff) | |
download | linux-stable-70424999fbf1f160ade111cb9baab51776e0f9c2.tar.gz linux-stable-70424999fbf1f160ade111cb9baab51776e0f9c2.tar.bz2 linux-stable-70424999fbf1f160ade111cb9baab51776e0f9c2.zip |
ACPI: custom_method: fix memory leaks
[ Upstream commit 03d1571d9513369c17e6848476763ebbd10ec2cb ]
In cm_write(), 'buf' is allocated through kzalloc(). In the following
execution, if an error occurs, 'buf' is not deallocated, leading to memory
leaks. To fix this issue, free 'buf' before returning the error.
Fixes: 526b4af47f44 ("ACPI: Split out custom_method functionality into an own driver")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/custom_method.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c index b2ef4c2ec955..fd66a736621c 100644 --- a/drivers/acpi/custom_method.c +++ b/drivers/acpi/custom_method.c @@ -49,8 +49,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf, if ((*ppos > max_size) || (*ppos + count > max_size) || (*ppos + count < count) || - (count > uncopied_bytes)) + (count > uncopied_bytes)) { + kfree(buf); return -EINVAL; + } if (copy_from_user(buf + (*ppos), user_buf, count)) { kfree(buf); @@ -70,6 +72,7 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf, add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE); } + kfree(buf); return count; } |