Skip to content

Commit 76e1fb4

Browse files
committed
nl80211: always check nla_nest_start() return value
If the message got full during nla_nest_start(), it can return NULL. None of the cases here seem like that can really happen, but check the return value nonetheless. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 58bd7f1 commit 76e1fb4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

net/wireless/nl80211.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8022,6 +8022,8 @@ __cfg80211_alloc_vendor_skb(struct cfg80211_registered_device *rdev,
80228022
}
80238023

80248024
data = nla_nest_start(skb, attr);
8025+
if (!data)
8026+
goto nla_put_failure;
80258027

80268028
((void **)skb->cb)[0] = rdev;
80278029
((void **)skb->cb)[1] = hdr;
@@ -9458,8 +9460,14 @@ static int nl80211_send_wowlan_nd(struct sk_buff *msg,
94589460

94599461
if (req->n_match_sets) {
94609462
matches = nla_nest_start(msg, NL80211_ATTR_SCHED_SCAN_MATCH);
9463+
if (!matches)
9464+
return -ENOBUFS;
9465+
94619466
for (i = 0; i < req->n_match_sets; i++) {
94629467
match = nla_nest_start(msg, i);
9468+
if (!match)
9469+
return -ENOBUFS;
9470+
94639471
nla_put(msg, NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
94649472
req->match_sets[i].ssid.ssid_len,
94659473
req->match_sets[i].ssid.ssid);
@@ -9474,6 +9482,9 @@ static int nl80211_send_wowlan_nd(struct sk_buff *msg,
94749482

94759483
for (i = 0; i < req->n_scan_plans; i++) {
94769484
scan_plan = nla_nest_start(msg, i + 1);
9485+
if (!scan_plan)
9486+
return -ENOBUFS;
9487+
94779488
if (!scan_plan ||
94789489
nla_put_u32(msg, NL80211_SCHED_SCAN_PLAN_INTERVAL,
94799490
req->scan_plans[i].interval) ||

0 commit comments

Comments
 (0)