From d8eca1105fe2039e102c6a8a915d0af937b1b593 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 29 Jun 2010 11:09:47 +0800 Subject: [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path The callers of write_acpi_int_ret() pass ACPI_ALLOCATE_BUFFER, the caller must kfree the returned buffer if AE_OK is returned. This patch adds a missing kfree(buffer.pointer) before return -ENOMEM if kstrdup fail. Signed-off-by: Axel Lin Acked-by: Corentin Chary Signed-off-by: Matthew Garrett --- drivers/platform/x86/asus-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index efe8f6388906..4af5709f8317 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -1397,8 +1397,10 @@ static int asus_laptop_get_info(struct asus_laptop *asus) } } asus->name = kstrdup(string, GFP_KERNEL); - if (!asus->name) + if (!asus->name) { + kfree(buffer.pointer); return -ENOMEM; + } if (*string) pr_notice(" %s model detected\n", string); -- 2.20.1