mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI: custom_method: fix a possible memory leak
@ 2023-11-11 13:24 shiqiang.deng
  2023-11-12 14:43 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: shiqiang.deng @ 2023-11-11 13:24 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, linux-kernel, shiqiang.deng

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 <shiqiang.deng213@gmail.com>
---
 drivers/acpi/custom_method.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index d39a9b474727..5103c7c3a6ce 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -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;
-- 
2.30.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-12 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-11 13:24 [PATCH] ACPI: custom_method: fix a possible memory leak shiqiang.deng
2023-11-12 14:43 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®