From patchwork Mon Sep 14 10:43:53 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 47282 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 n8EApUMC004623 for ; Mon, 14 Sep 2009 10:51:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750749AbZINKvZ (ORCPT ); Mon, 14 Sep 2009 06:51:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752631AbZINKvZ (ORCPT ); Mon, 14 Sep 2009 06:51:25 -0400 Received: from iksaif.net ([88.191.73.63]:44084 "EHLO iksaif.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750749AbZINKvY (ORCPT ); Mon, 14 Sep 2009 06:51:24 -0400 X-Greylist: delayed 458 seconds by postgrey-1.27 at vger.kernel.org; Mon, 14 Sep 2009 06:51:24 EDT Received: from localhost.localdomain (cxr69-11-88-180-139-205.fbx.proxad.net [88.180.139.205]) (Authenticated sender: corentincj@iksaif.net) by iksaif.net (Postfix) with ESMTPA id BB951C90031; Mon, 14 Sep 2009 12:44:47 +0200 (CEST) From: Corentin Chary To: linux-acpi@vger.kernel.org Cc: linux-kernel , Julia Lawall , Alan Jenkins , Johannes Berg , Corentin Chary , Matthew Garrett Subject: [PATCH 3/3] dell-laptop: fix rfkill memory leak on unload Date: Mon, 14 Sep 2009 12:43:53 +0200 Message-Id: <1252925033-29696-4-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: <1252925033-29696-3-git-send-email-corentincj@iksaif.net> References: <1252925033-29696-1-git-send-email-corentincj@iksaif.net> <1252925033-29696-2-git-send-email-corentincj@iksaif.net> <1252925033-29696-3-git-send-email-corentincj@iksaif.net> 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() Cc: Matthew Garrett Signed-off-by: Corentin Chary --- drivers/platform/x86/dell-laptop.c | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 74909c4..c81002c 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -206,6 +206,25 @@ static const struct rfkill_ops dell_rfkill_ops = { .query = dell_rfkill_query, }; +static void dell_free_rfkill(void) +{ + if (wifi_rfkill) { + rfkill_unregister(wifi_rfkill); + rfkill_destroy(wifi_rfkill); + wifi_rfkill = NULL; + } + if (bluetooth_rfkill) { + rfkill_unregister(bluetooth_rfkill); + rfkill_destroy(bluetooth_rfkill); + bluetooth_rfkill = NULL; + } + if (wwan_rfkill) { + rfkill_unregister(wwan_rfkill); + rfkill_destroy(wwan_rfkill); + wwan_rfkill = NULL; + } +} + static int dell_setup_rfkill(void) { struct calling_interface_buffer buffer; @@ -256,14 +275,17 @@ static int dell_setup_rfkill(void) return 0; err_wwan: rfkill_destroy(wwan_rfkill); + wwan_rfkill = NULL; if (bluetooth_rfkill) rfkill_unregister(bluetooth_rfkill); err_bluetooth: rfkill_destroy(bluetooth_rfkill); + bluetooth_rfkill = NULL; if (wifi_rfkill) rfkill_unregister(wifi_rfkill); err_wifi: rfkill_destroy(wifi_rfkill); + wifi_rfkill = NULL; return ret; } @@ -369,12 +391,7 @@ static int __init dell_init(void) return 0; out: - if (wifi_rfkill) - rfkill_unregister(wifi_rfkill); - if (bluetooth_rfkill) - rfkill_unregister(bluetooth_rfkill); - if (wwan_rfkill) - rfkill_unregister(wwan_rfkill); + dell_free_rfkill(); kfree(da_tokens); return ret; } @@ -382,12 +399,7 @@ out: 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_free_rfkill(); } module_init(dell_init);