Skip to content

Commit

Permalink
asus-laptop: fix a memory leak in asus_laptop_get_info error path
Browse files Browse the repository at this point in the history
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 <axel.lin@gmail.com>
Acked-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
  • Loading branch information
Axel Lin authored and Matthew Garrett committed Aug 3, 2010
1 parent 1492616 commit d8eca11
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/platform/x86/asus-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d8eca11

Please sign in to comment.