diff mbox

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

Message ID 1390580075-14342-1-git-send-email-hanjun.guo@linaro.org
State New
Headers show

Commit Message

Hanjun Guo Jan. 24, 2014, 4:14 p.m. UTC
we forgot to call wmi_free_devices() and free out.pointer
when alloc mamory failed.

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

Patch

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];