Skip to contentSkip to conversation

wistron_btns: fix a memory leak in wb_module_init error path

PATCH In review Axel Lin 2 participants 2 messages Jun 28, 2010

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 wistron_btns: fix a memory leak in wb_module_init error path

select_keymap calls copy_keymap to allocate a memory for keymap. This patch adds a missing kfree(keymap) in wb_module_init error path.

---
 drivers/input/misc/wistron_btns.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/input/misc/wistron_btns.c +1 -0
index 4dac8b7..55ce70e 100644
@@ -1371,6 +1371,7 @@ static int __init wb_module_init(void)
 	platform_driver_unregister(&wistron_driver);
  err_unmap_bios:
 	unmap_bios();
+	kfree(keymap);
 
 	return err;
 }
Signature · 1 line
1.5.4.3
maintainer
#1 lore raw

Hi Axel,

Quoted 13 lines · Axel Lin

select_keymap calls copy_keymap to allocate a memory for keymap. This patch adds a missing kfree(keymap) in wb_module_init error path.

---
 drivers/input/misc/wistron_btns.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/input/misc/wistron_btns.c +0 -0
index 4dac8b7..55ce70e 100644

drivers/input/misc/wistron_btns.c static int __init wb_module_init(void) · line 1374

Quoted 4 lines
drivers/input/misc/wistron_btns.c +1 -0
@@ -1371,6 +1371,7 @@ static int __init wb_module_init(void)
 	platform_driver_unregister(&wistron_driver);
  err_unmap_bios:
 	unmap_bios();
+	kfree(keymap);

Thank you for the patch, however this is not quite enough - we also need to free keymap when map_bios() call fails instead of returning immediately.

I fixed up locally and applied the patch.

Signature · 1 line
Dmitry