[PATCH] Platform / wmi: Fix potential memory leak in parse_wdg()

From: Hanjun Guo
Date: Fri Jan 24 2014 - 11:15:21 EST


we forgot to call wmi_free_devices() and free out.pointer
when alloc mamory failed.

Signed-off-by: Hanjun Guo <hanjun.guo@xxxxxxxxxx>
---
drivers/platform/x86/wmi.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 43d1329..e1338b5 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -797,8 +797,11 @@ static int parse_wdg(acpi_handle handle)
wmi_dump_wdg(&gblock[i]);

wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
- if (!wblock)
- return -ENOMEM;
+ if (!wblock) {
+ wmi_free_devices();
+ retval = -ENOMEM;
+ goto out_free_pointer;
+ }

wblock->handle = handle;
wblock->gblock = gblock[i];
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/