ACPI: custom_method: fix a possible memory leak
PATCH 1/1 ACPI: custom_method: fix a possible memory leak
In the cm_write() function, memory is allocated, and at the end of the function when uncopied_bytes is 0, the memory is freed. If uncopied_bytes is not equal to 0, a memory leak occurs.
Signed-off-by shiqiang.deng <[email protected]>
--- drivers/acpi/custom_method.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/custom_method.c +3 -0
@@ -77,6 +77,9 @@ static ssize_t cm_write(struct file *file, const char __user *user_buf,if (ACPI_FAILURE (status))return -EINVAL ;add_taint (TAINT_OVERRIDDEN_ACPI_TABLE ,LOCKDEP_NOW_UNRELIABLE ); + }else { +kfree (buf); + buf =NULL ; }return count;
Signature · 1 line
2.30.0
Rafael J. Wysocki
maintainerQuoted 16 lines · shiqiang.deng
In the
cm_write()function, memory is allocated, and at the end of the function whenuncopied_bytesis 0, the memory is freed. Ifuncopied_bytesis not equal to 0, a memory leak occurs.Signed-off-by shiqiang.deng <[email protected]>--- drivers/acpi/custom_method.c | 3 +++ 1 file changed, 3 insertions(+)drivers/acpi/custom_method.c +0
-0
drivers/acpi/custom_method.c static ssize_t cm_write(struct file *file, const char __user *user_buf,
Quoted 10 lines
drivers/acpi/custom_method.c +3
-1@@ -77,6 +77,9 @@ static ssize_t cm_write(struct file *file, const char __user *user_buf,if (ACPI_FAILURE (status))return -EINVAL ;add_taint (TAINT_OVERRIDDEN_ACPI_TABLE ,LOCKDEP_NOW_UNRELIABLE ); + }else { +kfree (buf); + buf =NULL ; }return count; --
That was discussed in the past and I still would rather drop this I/F completely instead of patching it for minor issues.