Skip to contentSkip to conversation

asus-laptop: fix a memory leak in asus_laptop_get_info error path

PATCH Applied Axel Lin 3 participants 3 messages Jun 29, 2010 – Jul 1, 2010

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/platform/x86/asus-laptop.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/platform/x86/asus-laptop.c +3 -1
index 71db2ef..3d76c6a 100644
@@ -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);
Signature · 1 line
1.5.4.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines · Axel Lin

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.

---
 drivers/platform/x86/asus-laptop.c |    4 +++-

 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/platform/x86/asus-laptop.c +3 -2
index 71db2ef..3d76c6a 100644
@@ -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);
--

1.5.4.3

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net
#2 lore raw
In reply to Axel Lin
Quoted 5 lines · Axel Lin

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.

Applied, thanks.

Signature · 1 line
Matthew Garrett | [email protected]