linux/drivers/net/wireless/ath
David S. Miller cf124db566 net: Fix inconsistent teardown and release of private netdev state.
Network devices can allocate reasources and private memory using
netdev_ops->ndo_init().  However, the release of these resources
can occur in one of two different places.

Either netdev_ops->ndo_uninit() or netdev->destructor().

The decision of which operation frees the resources depends upon
whether it is necessary for all netdev refs to be released before it
is safe to perform the freeing.

netdev_ops->ndo_uninit() presumably can occur right after the
NETDEV_UNREGISTER notifier completes and the unicast and multicast
address lists are flushed.

netdev->destructor(), on the other hand, does not run until the
netdev references all go away.

Further complicating the situation is that netdev->destructor()
almost universally does also a free_netdev().

This creates a problem for the logic in register_netdevice().
Because all callers of register_netdevice() manage the freeing
of the netdev, and invoke free_netdev(dev) if register_netdevice()
fails.

If netdev_ops->ndo_init() succeeds, but something else fails inside
of register_netdevice(), it does call ndo_ops->ndo_uninit().  But
it is not able to invoke netdev->destructor().

This is because netdev->destructor() will do a free_netdev() and
then the caller of register_netdevice() will do the same.

However, this means that the resources that would normally be released
by netdev->destructor() will not be.

Over the years drivers have added local hacks to deal with this, by
invoking their destructor parts by hand when register_netdevice()
fails.

Many drivers do not try to deal with this, and instead we have leaks.

Let's close this hole by formalizing the distinction between what
private things need to be freed up by netdev->destructor() and whether
the driver needs unregister_netdevice() to perform the free_netdev().

netdev->priv_destructor() performs all actions to free up the private
resources that used to be freed by netdev->destructor(), except for
free_netdev().

netdev->needs_free_netdev is a boolean that indicates whether
free_netdev() should be done at the end of unregister_netdevice().

Now, register_netdevice() can sanely release all resources after
ndo_ops->ndo_init() succeeds, by invoking both ndo_ops->ndo_uninit()
and netdev->priv_destructor().

And at the end of unregister_netdevice(), we invoke
netdev->priv_destructor() and optionally call free_netdev().

Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-07 15:53:24 -04:00
..
ar5523 wireless: Set NL80211_EXT_FEATURE_CQM_RSSI_LIST in multiple drivers 2017-03-06 09:21:39 +01:00
ath5k mac80211: separate encoding/bandwidth from flags 2017-04-28 10:41:45 +02:00
ath6kl net: Fix inconsistent teardown and release of private netdev state. 2017-06-07 15:53:24 -04:00
ath9k mac80211: properly remove RX_ENC_FLAG_40MHZ 2017-05-08 11:11:56 +02:00
ath10k mac80211: rename ieee80211_rx_status::vht_nss to just nss 2017-04-28 10:41:53 +02:00
carl9170 mac80211: separate encoding/bandwidth from flags 2017-04-28 10:41:45 +02:00
wcn36xx wcn36xx: Close SMD channel on device removal 2017-05-23 18:23:00 +03:00
wil6210 wireless-drivers-next patches for 4.12 2017-04-24 12:25:01 -04:00
ath.h ath9k: add a helper to get the string representation of ath_bus_type 2016-11-15 16:55:37 +02:00
debug.c ath: Make ath_opmode_to_string understand OCB mode 2015-08-10 22:21:15 +03:00
dfs_pattern_detector.c ath: constify local structures 2016-09-14 20:01:39 +03:00
dfs_pattern_detector.h ath: use PRI value given by spec for fixed PRI 2015-09-27 15:50:30 +03:00
dfs_pri_detector.c ath: use PRI value given by spec for fixed PRI 2015-09-27 15:50:30 +03:00
dfs_pri_detector.h
hw.c
Kconfig ath: unify Kconfig with other vendors 2015-11-18 14:28:31 +02:00
key.c
main.c ath9k: add a helper to get the string representation of ath_bus_type 2016-11-15 16:55:37 +02:00
Makefile Makefile: drop -D__CHECK_ENDIAN__ from cflags 2016-12-16 00:13:43 +02:00
reg.h
regd.c ath: Fix updating radar flags for coutry code India 2017-04-19 17:09:26 +03:00
regd.h ath: export alpha2 helper 2016-10-04 18:01:48 +03:00
regd_common.h
spectral_common.h
trace.c
trace.h