Skip to content

Commit

Permalink
wifi: cfg80211: Move cfg80211_scan_req_add_chan() n_channels incremen…
Browse files Browse the repository at this point in the history
…t earlier

Since adding __counted_by(n_channels) to struct cfg80211_scan_request,
anything adding to the channels array must increment n_channels first.
Move n_channels increment earlier.

Reported-by: John Rowley <lkml@johnrowley.me>
Closes: https://lore.kernel.org/stable/1815535c709ba9d9.156c6a5c9cdf6e59.b249b6b6a5ee4634@localhost.localdomain/
Fixes: aa4ec06 ("wifi: cfg80211: use __counted_by where appropriate")
Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://patch.msgid.link/20241230183610.work.680-kees@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Kees Cook authored and Johannes Berg committed Jan 13, 2025
1 parent 7553477 commit 3a01686
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/wireless/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,12 +799,11 @@ static void cfg80211_scan_req_add_chan(struct cfg80211_scan_request *request,
}
}

request->n_channels++;
request->channels[n_channels] = chan;
if (add_to_6ghz)
request->scan_6ghz_params[request->n_6ghz_params].channel_idx =
n_channels;

request->n_channels++;
}

static bool cfg80211_find_ssid_match(struct cfg80211_colocated_ap *ap,
Expand Down

0 comments on commit 3a01686

Please sign in to comment.