linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dell-wmi: fix a memory leak
@ 2010-06-30  9:25 Axel Lin
  2010-07-01 13:53 ` Matthew Garrett
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2010-06-30  9:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Matthew Garrett, Len Brown, Dmitry Torokhov,
	Márton Németh, platform-driver-x86

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.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/platform/x86/dell-wmi.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
index 66f53c3..ee6452e 100644
--- a/drivers/platform/x86/dell-wmi.c
+++ b/drivers/platform/x86/dell-wmi.c
@@ -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);
-- 
1.5.4.3




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dell-wmi: fix a memory leak
  2010-06-30  9:25 [PATCH] dell-wmi: fix a memory leak Axel Lin
@ 2010-07-01 13:53 ` Matthew Garrett
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Garrett @ 2010-07-01 13:53 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Len Brown, Dmitry Torokhov,
	Márton Németh, platform-driver-x86

On Wed, Jun 30, 2010 at 05:25:46PM +0800, Axel Lin wrote:
> 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.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-01 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30  9:25 [PATCH] dell-wmi: fix a memory leak Axel Lin
2010-07-01 13:53 ` Matthew Garrett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).