From patchwork Wed Aug 19 14:06:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Jenkins X-Patchwork-Id: 42699 X-Patchwork-Delegate: lenb@kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7JEHZjJ030881 for ; Wed, 19 Aug 2009 14:17:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752569AbZHSORb (ORCPT ); Wed, 19 Aug 2009 10:17:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752021AbZHSORb (ORCPT ); Wed, 19 Aug 2009 10:17:31 -0400 Received: from fallback-out2.mxes.net ([216.86.168.191]:54170 "EHLO fallback-in2.mxes.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751361AbZHSORa (ORCPT ); Wed, 19 Aug 2009 10:17:30 -0400 Received: from mxout-08.mxes.net (mxout-08.mxes.net [216.86.168.183]) by fallback-in1.mxes.net (Postfix) with ESMTP id 0C0892FDBEA; Wed, 19 Aug 2009 10:08:13 -0400 (EDT) Received: from localhost.localdomain (unknown [86.53.68.233]) by smtp.mxes.net (Postfix) with ESMTPA id 82896509DD; Wed, 19 Aug 2009 10:07:07 -0400 (EDT) From: Alan Jenkins To: mjg@redhat.com Cc: marcel@holtmann.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, Alan Jenkins Subject: [PATCH 2/5] dell-laptop: fix rfkill memory leak on unload and failure paths Date: Wed, 19 Aug 2009 15:06:48 +0100 Message-Id: <1250690811-21203-2-git-send-email-alan-jenkins@tuffmail.co.uk> X-Mailer: git-send-email 1.6.3.2 In-Reply-To: <4A8C0623.8030808@tuffmail.co.uk> References: <4A8C0623.8030808@tuffmail.co.uk> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org rfkill_unregister() should always be followed by rfkill_destroy(). Signed-off-by: Alan Jenkins --- drivers/platform/x86/dell-laptop.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 12b6f33..8fbff38 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -268,6 +268,22 @@ err_wifi: 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; @@ -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; @@ -384,12 +395,7 @@ fail_rfkill: 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);