Commit d8eca1105fe2039e102c6a8a915d0af937b1b593

Authored by Axel Lin
Committed by Matthew Garrett
1 parent 1492616a43

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 <axel.lin@gmail.com>
Acked-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

drivers/platform/x86/asus-laptop.c
... ... @@ -1397,8 +1397,10 @@
1397 1397 }
1398 1398 }
1399 1399 asus->name = kstrdup(string, GFP_KERNEL);
1400   - if (!asus->name)
  1400 + if (!asus->name) {
  1401 + kfree(buffer.pointer);
1401 1402 return -ENOMEM;
  1403 + }
1402 1404  
1403 1405 if (*string)
1404 1406 pr_notice(" %s model detected\n", string);