Skip to content

Commit

Permalink
dell-laptop: fix rfkill memory leak on unload and failure paths
Browse files Browse the repository at this point in the history
rfkill_unregister() should always be followed by rfkill_destroy().

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Alan Jenkins authored and Len Brown committed Dec 10, 2009
1 parent 71e9dc7 commit 4311bb2
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions drivers/platform/x86/dell-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,22 @@ static int dell_setup_rfkill(void)
return ret;
}

static void dell_cleanup_rfkill(void)
{
if (wifi_rfkill) {
rfkill_unregister(wifi_rfkill);
rfkill_destroy(wifi_rfkill);
}
if (bluetooth_rfkill) {
rfkill_unregister(bluetooth_rfkill);
rfkill_destroy(bluetooth_rfkill);
}
if (wwan_rfkill) {
rfkill_unregister(wwan_rfkill);
rfkill_destroy(wwan_rfkill);
}
}

static int dell_send_intensity(struct backlight_device *bd)
{
struct calling_interface_buffer buffer;
Expand Down Expand Up @@ -370,12 +386,7 @@ static int __init dell_init(void)
return 0;

fail_backlight:
if (wifi_rfkill)
rfkill_unregister(wifi_rfkill);
if (bluetooth_rfkill)
rfkill_unregister(bluetooth_rfkill);
if (wwan_rfkill)
rfkill_unregister(wwan_rfkill);
dell_cleanup_rfkill();
fail_rfkill:
kfree(da_tokens);
return ret;
Expand All @@ -384,12 +395,7 @@ static int __init dell_init(void)
static void __exit dell_exit(void)
{
backlight_device_unregister(dell_backlight_device);
if (wifi_rfkill)
rfkill_unregister(wifi_rfkill);
if (bluetooth_rfkill)
rfkill_unregister(bluetooth_rfkill);
if (wwan_rfkill)
rfkill_unregister(wwan_rfkill);
dell_cleanup_rfkill();
}

module_init(dell_init);
Expand Down

0 comments on commit 4311bb2

Please sign in to comment.