aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2010-06-02 23:45:45 -0400
committerMatthew Garrett <mjg@redhat.com>2010-08-03 09:48:49 -0400
commita5167c5b3a842b865b0ca87202b95cc8a84c9e7e (patch)
tree306e318b77177938973b4f98a38c5e5a3482c7bc
parent410d44c74cf9942e3055d5b7d73953fac8efbacb (diff)
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>
-rw-r--r--drivers/platform/x86/wmi.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index e4eaa14ed987..582b5cdd3f43 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -827,8 +827,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
827 total = obj->buffer.length / sizeof(struct guid_block); 827 total = obj->buffer.length / sizeof(struct guid_block);
828 828
829 gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL); 829 gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
830 if (!gblock) 830 if (!gblock) {
831 return AE_NO_MEMORY; 831 status = AE_NO_MEMORY;
832 goto out_free_pointer;
833 }
832 834
833 for (i = 0; i < total; i++) { 835 for (i = 0; i < total; i++) {
834 /* 836 /*
@@ -848,8 +850,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
848 wmi_dump_wdg(&gblock[i]); 850 wmi_dump_wdg(&gblock[i]);
849 851
850 wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); 852 wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
851 if (!wblock) 853 if (!wblock) {
852 return AE_NO_MEMORY; 854 status = AE_NO_MEMORY;
855 goto out_free_gblock;
856 }
853 857
854 wblock->gblock = gblock[i]; 858 wblock->gblock = gblock[i];
855 wblock->handle = handle; 859 wblock->handle = handle;
@@ -860,8 +864,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
860 list_add_tail(&wblock->list, &wmi_blocks.list); 864 list_add_tail(&wblock->list, &wmi_blocks.list);
861 } 865 }
862 866
863 kfree(out.pointer); 867out_free_gblock:
864 kfree(gblock); 868 kfree(gblock);
869out_free_pointer:
870 kfree(out.pointer);
865 871
866 return status; 872 return status;
867} 873}