wmi: fix memory leak in parse_wdg
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>
This commit is contained in:
committed by
Matthew Garrett
parent
410d44c74c
commit
a5167c5b3a
@@ -827,8 +827,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
|
|||||||
total = obj->buffer.length / sizeof(struct guid_block);
|
total = obj->buffer.length / sizeof(struct guid_block);
|
||||||
|
|
||||||
gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
|
gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
|
||||||
if (!gblock)
|
if (!gblock) {
|
||||||
return AE_NO_MEMORY;
|
status = AE_NO_MEMORY;
|
||||||
|
goto out_free_pointer;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < total; i++) {
|
for (i = 0; i < total; i++) {
|
||||||
/*
|
/*
|
||||||
@@ -848,8 +850,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
|
|||||||
wmi_dump_wdg(&gblock[i]);
|
wmi_dump_wdg(&gblock[i]);
|
||||||
|
|
||||||
wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
|
wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
|
||||||
if (!wblock)
|
if (!wblock) {
|
||||||
return AE_NO_MEMORY;
|
status = AE_NO_MEMORY;
|
||||||
|
goto out_free_gblock;
|
||||||
|
}
|
||||||
|
|
||||||
wblock->gblock = gblock[i];
|
wblock->gblock = gblock[i];
|
||||||
wblock->handle = handle;
|
wblock->handle = handle;
|
||||||
@@ -860,8 +864,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
|
|||||||
list_add_tail(&wblock->list, &wmi_blocks.list);
|
list_add_tail(&wblock->list, &wmi_blocks.list);
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(out.pointer);
|
out_free_gblock:
|
||||||
kfree(gblock);
|
kfree(gblock);
|
||||||
|
out_free_pointer:
|
||||||
|
kfree(out.pointer);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user