]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mwifiex: fix memory leak issue when driver unload
authorAmitkumar Karwar <akarwar@marvell.com>
Tue, 7 May 2013 02:46:54 +0000 (19:46 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 30 May 2013 13:34:54 +0000 (14:34 +0100)
commit f16fdc9d2dc1e5b270e9a08377587e831e0d36ac upstream.

After unregister_netdevice() call the request is queued and
reg_state is changed to NETREG_UNREGISTERING.
As we check for NETREG_UNREGISTERED state, free_netdev() never
gets executed causing memory leak.

Initialize "dev->destructor" to free_netdev() to free device
data after unregistration.

Reported-by: Daniel Drake <dsd@laptop.org>
Tested-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
[bwh: Backported to 3.2: s/wdev->netdev/dev/]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/main.c

index 727c12966d1d9c24aaf7fce043560f67556a6916..45ac407deda9a7b2b9e495ec484cd4543cd21b0c 100644 (file)
@@ -1281,9 +1281,6 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev)
        if (dev->reg_state == NETREG_REGISTERED)
                unregister_netdevice(dev);
 
-       if (dev->reg_state == NETREG_UNREGISTERED)
-               free_netdev(dev);
-
        /* Clear the priv in adapter */
        priv->netdev = NULL;
 
index 67e6db7d672ddf5fbeb614395bdda7c76b2dab56..5baa12afabd46fa9ba2ac10f74994a508e31315c 100644 (file)
@@ -581,6 +581,7 @@ void mwifiex_init_priv_params(struct mwifiex_private *priv,
                                                struct net_device *dev)
 {
        dev->netdev_ops = &mwifiex_netdev_ops;
+       dev->destructor = free_netdev;
        /* Initialize private structure */
        priv->current_key_index = 0;
        priv->media_connected = false;