diff options
author | Wenwen Wang <wenwen@cs.uga.edu> | 2019-08-16 01:08:27 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-09-02 17:17:22 -0400 |
commit | 03d1571d9513369c17e6848476763ebbd10ec2cb (patch) | |
tree | 296fde035b930983a1e68cee556d6dfd30e16f4c | |
parent | 5c7ed4385424b1c2ce0c27c41448e080e44ebb09 (diff) |
ACPI: custom_method: fix memory leaks
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>
-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, | |||
49 | if ((*ppos > max_size) || | 49 | if ((*ppos > max_size) || |
50 | (*ppos + count > max_size) || | 50 | (*ppos + count > max_size) || |
51 | (*ppos + count < count) || | 51 | (*ppos + count < count) || |
52 | (count > uncopied_bytes)) | 52 | (count > uncopied_bytes)) { |
53 | kfree(buf); | ||
53 | return -EINVAL; | 54 | return -EINVAL; |
55 | } | ||
54 | 56 | ||
55 | if (copy_from_user(buf + (*ppos), user_buf, count)) { | 57 | if (copy_from_user(buf + (*ppos), user_buf, count)) { |
56 | kfree(buf); | 58 | kfree(buf); |
@@ -70,6 +72,7 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf, | |||
70 | add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE); | 72 | add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE); |
71 | } | 73 | } |
72 | 74 | ||
75 | kfree(buf); | ||
73 | return count; | 76 | return count; |
74 | } | 77 | } |
75 | 78 | ||