Skip to content

Commit d220c49

Browse files
committed
wifi: mac80211: simplify return value handling of cfg80211_get_radio_idx_by_chan()
JIRA: https://issues.redhat.com/browse/RHEL-114891 commit cfb58d5 Author: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com> Date: Tue Aug 12 12:53:29 2025 +0530 wifi: mac80211: simplify return value handling of cfg80211_get_radio_idx_by_chan() In several instances where cfg80211_get_radio_idx_by_chan() is called, redundant checks are performed across function — such as verifying if wiphy->n_radio < 2 or if the returned index is negative. These checks are unnecessary, as the return value can be directly compared. Moreover, the function can be safely called even when radio-level properties are not explicitly advertised since in such case in each call it is going to get same error value. Therefore, simplify the usage of this function across all such cases by removing redundant conditions and relying on the return value directly. Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com> Link: https://patch.msgid.link/20250812-fix_scan_ap_flag_requirement_during_mlo-v4-2-383ffb6da213@oss.qualcomm.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
1 parent 3c97974 commit d220c49

File tree

3 files changed

+6
-33
lines changed

3 files changed

+6
-33
lines changed

net/mac80211/cfg.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,12 +3690,7 @@ static bool ieee80211_is_scan_ongoing(struct wiphy *wiphy,
36903690
if (list_empty(&local->roc_list) && !local->scanning)
36913691
return false;
36923692

3693-
if (wiphy->n_radio < 2)
3694-
return true;
3695-
36963693
req_radio_idx = cfg80211_get_radio_idx_by_chan(wiphy, chandef->chan);
3697-
if (req_radio_idx < 0)
3698-
return true;
36993694

37003695
if (local->scanning) {
37013696
scan_req = wiphy_dereference(wiphy, local->scan_req);
@@ -3714,14 +3709,6 @@ static bool ieee80211_is_scan_ongoing(struct wiphy *wiphy,
37143709
list_for_each_entry(roc, &local->roc_list, list) {
37153710
chan_radio_idx = cfg80211_get_radio_idx_by_chan(wiphy,
37163711
roc->chan);
3717-
/*
3718-
* The roc work is added but chan_radio_idx is invalid.
3719-
* Should not happen but if it does, let's not take
3720-
* risk and return true.
3721-
*/
3722-
if (chan_radio_idx < 0)
3723-
return true;
3724-
37253712
if (chan_radio_idx == req_radio_idx)
37263713
return true;
37273714
}

net/mac80211/chan.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -659,19 +659,8 @@ bool ieee80211_is_radar_required(struct ieee80211_local *local,
659659

660660
for_each_sdata_link(local, link) {
661661
if (link->radar_required) {
662-
if (wiphy->n_radio < 2)
663-
return true;
664-
665662
chan = link->conf->chanreq.oper.chan;
666663
radio_idx = cfg80211_get_radio_idx_by_chan(wiphy, chan);
667-
/*
668-
* The radio index (radio_idx) is expected to be valid,
669-
* as it's derived from a channel tied to a link. If
670-
* it's invalid (i.e., negative), return true to avoid
671-
* potential issues with radar-sensitive operations.
672-
*/
673-
if (radio_idx < 0)
674-
return true;
675664

676665
if (ieee80211_is_radio_idx_in_scan_req(wiphy, req,
677666
radio_idx))

net/mac80211/util.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4022,16 +4022,13 @@ bool ieee80211_is_radio_idx_in_scan_req(struct wiphy *wiphy,
40224022
for (i = 0; i < scan_req->n_channels; i++) {
40234023
chan = scan_req->channels[i];
40244024
chan_radio_idx = cfg80211_get_radio_idx_by_chan(wiphy, chan);
4025-
/*
4026-
* The chan_radio_idx should be valid since it's taken from a
4027-
* valid scan request.
4028-
* However, if chan_radio_idx is unexpectedly invalid (negative),
4029-
* we take a conservative approach and assume the scan request
4030-
* might use the specified radio_idx. Hence, return true.
4031-
*/
4032-
if (WARN_ON(chan_radio_idx < 0))
4033-
return true;
40344025

4026+
/* The radio index either matched successfully, or an error
4027+
* occurred. For example, if radio-level information is
4028+
* missing, the same error value is returned. This
4029+
* typically implies a single-radio setup, in which case
4030+
* the operation should not be allowed.
4031+
*/
40354032
if (chan_radio_idx == radio_idx)
40364033
return true;
40374034
}

0 commit comments

Comments
 (0)