]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
wifi: cfg80211: sme: init n_channels before channels[] access
authorHaoyu Li <lihaoyu499@gmail.com>
Tue, 3 Dec 2024 15:20:49 +0000 (23:20 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 6 Dec 2024 09:45:22 +0000 (10:45 +0100)
With the __counted_by annocation in cfg80211_scan_request struct,
the "n_channels" struct member must be set before accessing the
"channels" array. Failing to do so will trigger a runtime warning
when enabling CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by")
Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
Link: https://patch.msgid.link/20241203152049.348806-1-lihaoyu499@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/sme.c

index 431da30817a6f6321238fd94f834d3c64127c50c..26817160008766c5be426a913f548e006677d515 100644 (file)
@@ -83,6 +83,7 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
        if (!request)
                return -ENOMEM;
 
+       request->n_channels = n_channels;
        if (wdev->conn->params.channel) {
                enum nl80211_band band = wdev->conn->params.channel->band;
                struct ieee80211_supported_band *sband =