From 7371400431389e1df6a2a05ab9882055b8a6ff2c Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 29 Mar 2010 17:14:18 +0200 Subject: [PATCH] net/wireless/libertas: do not call wiphy_unregister() w/o wiphy_register() The libertas driver calls wiphy_unregister() without a prior wiphy_register() when a devices fails initialization. Fix this by introducing a private flag. [ 9.310000] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [...] [ 9.330000] [] (wiphy_unregister+0xfc/0x19c) from [] (lbs_cfg_free+0x70/0x9c [libertas]) [ 9.330000] [] (lbs_cfg_free+0x70/0x9c [libertas]) from [] (lbs_remove_card+0x180/0x210 [libertas]) [ 9.330000] [] (lbs_remove_card+0x180/0x210 [libertas]) from [] (if_sdio_probe+0xdc4/0xef4 [libertas_sdio]) [ 9.330000] [] (if_sdio_probe+0xdc4/0xef4 [libertas_sdio]) from [] (sdio_bus_probe+0xd4/0xf0) [ 9.330000] [] (sdio_bus_probe+0xd4/0xf0) from [] (driver_probe_device+0xa4/0x174) [ 9.330000] [] (driver_probe_device+0xa4/0x174) from [] (__driver_attach+0x60/0x84) [ 9.330000] [] (__driver_attach+0x60/0x84) from [] (bus_for_each_dev+0x4c/0x8c) [ 9.330000] [] (bus_for_each_dev+0x4c/0x8c) from [] (bus_add_driver+0xa0/0x228) [ 9.330000] [] (bus_add_driver+0xa0/0x228) from [] (driver_register+0xc0/0x150) [ 9.330000] [] (driver_register+0xc0/0x150) from [] (if_sdio_init_module+0x6c/0x108 [libertas_sdio]) [ 9.330000] [] (if_sdio_init_module+0x6c/0x108 [libertas_sdio]) from [] (do_one_initcall+0x5c/0x1bc) [ 9.330000] [] (do_one_initcall+0x5c/0x1bc) from [] (sys_init_module+0xc0/0x1f0) [ 9.330000] [] (sys_init_module+0xc0/0x1f0) from [] (ret_fast_syscall+0x0/0x30) Signed-off-by: Daniel Mack Cc: Dan Williams Cc: John W. Linville Cc: Holger Schurig Cc: Bing Zhao Cc: libertas-dev@lists.infradead.org Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: John W. Linville --- drivers/net/wireless/libertas/cfg.c | 8 ++++++-- drivers/net/wireless/libertas/dev.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index 4396dcc..82ebe14 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c @@ -172,6 +172,8 @@ int lbs_cfg_register(struct lbs_private *priv) if (ret < 0) lbs_pr_err("cannot register wiphy device\n"); + priv->wiphy_registered = true; + ret = register_netdev(priv->dev); if (ret) lbs_pr_err("cannot register network device\n"); @@ -190,9 +192,11 @@ void lbs_cfg_free(struct lbs_private *priv) if (!wdev) return; - if (wdev->wiphy) { + if (priv->wiphy_registered) wiphy_unregister(wdev->wiphy); + + if (wdev->wiphy) wiphy_free(wdev->wiphy); - } + kfree(wdev); } diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h index 6977ee8..6875e14 100644 --- a/drivers/net/wireless/libertas/dev.h +++ b/drivers/net/wireless/libertas/dev.h @@ -36,6 +36,7 @@ struct lbs_private { /* CFG80211 */ struct wireless_dev *wdev; + bool wiphy_registered; /* Mesh */ struct net_device *mesh_dev; /* Virtual device */ -- 2.7.4