Skip to content

Commit f4695c1

Browse files
SvirusxMrR0b0X
authored andcommitted
FIX kernel panic after plugin USB WiFi Adapter - notifier NULL pointer dereference
1 parent fd9ef6a commit f4695c1

3 files changed

Lines changed: 39 additions & 9 deletions

File tree

drivers/net/wireless/bcmdhd/wl_cfg80211.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10903,13 +10903,23 @@ wl_cfg80211_netdev_notifier_call(struct notifier_block * nb,
1090310903
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1090410904
#endif /* LINUX_VERSION < VERSION(3, 11, 0) */
1090510905

10906-
struct wireless_dev *wdev = ndev_to_wdev(dev);
10907-
struct bcm_cfg80211 *cfg = g_bcm_cfg;
10906+
struct wireless_dev *wdev;
10907+
struct bcm_cfg80211 *cfg;
1090810908

1090910909
WL_DBG(("Enter \n"));
10910+
if (!dev || !ndev_to_wdev(dev))
10911+
return NOTIFY_DONE;
1091010912

10911-
if (!wdev || !cfg || dev == bcmcfg_to_prmry_ndev(cfg))
10913+
cfg = wl_get_cfg(dev);
10914+
if ((!cfg || ndev_to_wdev(dev) != cfg->wdev)) {
1091210915
return NOTIFY_DONE;
10916+
}
10917+
10918+
if (dev == bcmcfg_to_prmry_ndev(cfg)) {
10919+
return NOTIFY_DONE;
10920+
}
10921+
10922+
wdev = ndev_to_wdev(dev);
1091310923

1091410924
switch (state) {
1091510925
case NETDEV_DOWN:

drivers/net/wireless/bcmdhd_1_77/wl_cfg80211.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15084,13 +15084,23 @@ wl_cfg80211_netdev_notifier_call(struct notifier_block * nb,
1508415084
#else
1508515085
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1508615086
#endif /* LINUX_VERSION < VERSION(3, 11, 0) */
15087-
struct wireless_dev *wdev = ndev_to_wdev(dev);
15088-
struct bcm_cfg80211 *cfg = wl_get_cfg(dev);
15087+
struct wireless_dev *wdev;
15088+
struct bcm_cfg80211 *cfg;
1508915089

1509015090
WL_DBG(("Enter \n"));
15091+
if (!dev || !ndev_to_wdev(dev))
15092+
return NOTIFY_DONE;
1509115093

15092-
if (!wdev || !cfg || dev == bcmcfg_to_prmry_ndev(cfg))
15094+
cfg = wl_get_cfg(dev);
15095+
if ((!cfg || ndev_to_wdev(dev) != cfg->wdev)) {
1509315096
return NOTIFY_DONE;
15097+
}
15098+
15099+
if (dev == bcmcfg_to_prmry_ndev(cfg)) {
15100+
return NOTIFY_DONE;
15101+
}
15102+
15103+
wdev = ndev_to_wdev(dev);
1509415104

1509515105
switch (state) {
1509615106
case NETDEV_DOWN:

drivers/net/wireless/bcmdhd_1_77_nn/wl_cfg80211.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14705,13 +14705,23 @@ wl_cfg80211_netdev_notifier_call(struct notifier_block * nb,
1470514705
#else
1470614706
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1470714707
#endif /* LINUX_VERSION < VERSION(3, 11, 0) */
14708-
struct wireless_dev *wdev = ndev_to_wdev(dev);
14709-
struct bcm_cfg80211 *cfg = wl_get_cfg(dev);
14708+
struct wireless_dev *wdev;
14709+
struct bcm_cfg80211 *cfg;
1471014710

1471114711
WL_DBG(("Enter \n"));
14712+
if (!dev || !ndev_to_wdev(dev))
14713+
return NOTIFY_DONE;
1471214714

14713-
if (!wdev || !cfg || dev == bcmcfg_to_prmry_ndev(cfg))
14715+
cfg = wl_get_cfg(dev);
14716+
if ((!cfg || ndev_to_wdev(dev) != cfg->wdev)) {
1471414717
return NOTIFY_DONE;
14718+
}
14719+
14720+
if (dev == bcmcfg_to_prmry_ndev(cfg)) {
14721+
return NOTIFY_DONE;
14722+
}
14723+
14724+
wdev = ndev_to_wdev(dev);
1471514725

1471614726
switch (state) {
1471714727
case NETDEV_DOWN:

0 commit comments

Comments
 (0)