Skip to content

Commit

Permalink
cfg80211:: fix possible NULL pointer dereference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mkozlowski authored and linvjw committed Mar 28, 2011
1 parent 67aa030 commit bef9bac
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/wireless/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,16 +585,23 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy,
struct cfg80211_internal_bss *res;
size_t ielen = len - offsetof(struct ieee80211_mgmt,
u.probe_resp.variable);
size_t privsz = wiphy->bss_priv_size;
size_t privsz;

if (WARN_ON(!mgmt))
return NULL;

if (WARN_ON(!wiphy))
return NULL;

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

if (WARN_ON(!mgmt || !wiphy ||
len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable)))
if (WARN_ON(len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable)))
return NULL;

privsz = wiphy->bss_priv_size;

res = kzalloc(sizeof(*res) + privsz + ielen, gfp);
if (!res)
return NULL;
Expand Down

0 comments on commit bef9bac

Please sign in to comment.