Skip to content

Commit

Permalink
wmi: fix memory leak in parse_wdg
Browse files Browse the repository at this point in the history
This patch properly kfree out.pointer and gblock in error path.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
  • Loading branch information
Axel Lin authored and Matthew Garrett committed Aug 3, 2010
1 parent 410d44c commit a5167c5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions drivers/platform/x86/wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
total = obj->buffer.length / sizeof(struct guid_block);

gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
if (!gblock)
return AE_NO_MEMORY;
if (!gblock) {
status = AE_NO_MEMORY;
goto out_free_pointer;
}

for (i = 0; i < total; i++) {
/*
Expand All @@ -848,8 +850,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
wmi_dump_wdg(&gblock[i]);

wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
if (!wblock)
return AE_NO_MEMORY;
if (!wblock) {
status = AE_NO_MEMORY;
goto out_free_gblock;
}

wblock->gblock = gblock[i];
wblock->handle = handle;
Expand All @@ -860,8 +864,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
list_add_tail(&wblock->list, &wmi_blocks.list);
}

kfree(out.pointer);
out_free_gblock:
kfree(gblock);
out_free_pointer:
kfree(out.pointer);

return status;
}
Expand Down

0 comments on commit a5167c5

Please sign in to comment.