Skip to content

Commit bef9bac

Browse files
mkozlowskilinvjw
authored andcommitted
cfg80211:: fix possible NULL pointer dereference
In cfg80211_inform_bss_frame() wiphy is first dereferenced on privsz initialisation and then it is checked for NULL. This patch fixes that. Signed-off-by: Mariusz Kozlowski <mk@lab.zgora.pl> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 67aa030 commit bef9bac

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎net/wireless/scan.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,16 +585,23 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy,
585585
struct cfg80211_internal_bss *res;
586586
size_t ielen = len - offsetof(struct ieee80211_mgmt,
587587
u.probe_resp.variable);
588-
size_t privsz = wiphy->bss_priv_size;
588+
size_t privsz;
589+
590+
if (WARN_ON(!mgmt))
591+
return NULL;
592+
593+
if (WARN_ON(!wiphy))
594+
return NULL;
589595

590596
if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC &&
591597
(signal < 0 || signal > 100)))
592598
return NULL;
593599

594-
if (WARN_ON(!mgmt || !wiphy ||
595-
len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable)))
600+
if (WARN_ON(len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable)))
596601
return NULL;
597602

603+
privsz = wiphy->bss_priv_size;
604+
598605
res = kzalloc(sizeof(*res) + privsz + ielen, gfp);
599606
if (!res)
600607
return NULL;

0 commit comments

Comments
 (0)