Skip to contentSkip to conversation

dell-wmi: fix a memory leak

PATCH Applied Axel Lin 2 participants 2 messages Jun 30, 2010 – Jul 1, 2010 x86 platform drivers

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 dell-wmi: fix a memory leak

If dell_new_hk_type is true, dell_legacy_wmi_keymap will point to a memory allocated in setup_new_hk_map().
In this case, the memory is not freed in current implementation. This patch fixes the leak by kfree(dell_wmi_keymap) if dell_new_hk_type is true.

---
 drivers/platform/x86/dell-wmi.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/platform/x86/dell-wmi.c +8 -1
index 66f53c3..ee6452e 100644
@@ -339,13 +339,18 @@ static int __init dell_wmi_init(void)
 	acpi_video = acpi_video_backlight_support();
 
 	err = dell_wmi_input_setup();
-	if (err)
+	if (err) {
+		if (dell_new_hk_type)
+			kfree(dell_wmi_keymap);
 		return err;
+	}
 
 	status = wmi_install_notify_handler(DELL_EVENT_GUID,
 					 dell_wmi_notify, NULL);
 	if (ACPI_FAILURE(status)) {
 		input_unregister_device(dell_wmi_input_dev);
+		if (dell_new_hk_type)
+			kfree(dell_wmi_keymap);
 		printk(KERN_ERR
 			"dell-wmi: Unable to register notify handler - %d\n",
 			status);
@@ -359,6 +364,8 @@ static void __exit dell_wmi_exit(void)
 {
 	wmi_remove_notify_handler(DELL_EVENT_GUID);
 	input_unregister_device(dell_wmi_input_dev);
+	if (dell_new_hk_type)
+		kfree(dell_wmi_keymap);
 }
 
 module_init(dell_wmi_init);
Signature · 1 line
1.5.4.3
#1 lore raw
Quoted 6 lines · Axel Lin

If dell_new_hk_type is true, dell_legacy_wmi_keymap will point to a memory allocated in setup_new_hk_map().
In this case, the memory is not freed in current implementation. This patch fixes the leak by kfree(dell_wmi_keymap) if dell_new_hk_type is true.

Applied, thanks.

Signature · 1 line
Matthew Garrett | [email protected]