All of lore.kernel.org
 help / color / mirror / Atom feed
* [ath:ath-next 24/34] net/wireless/nl80211.c:4433 nl80211_set_wiphy() warn: iterator used outside loop: 'wdev'
@ 2026-10-14  3:47 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-10-14  3:47 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

Unfiltered warning: this smatch report is sent as-is and has not been
reviewed for false positives, so please treat it with due skepticism.

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: Jeff Johnson <jjohnson@kernel.org>
CC: ath12k@lists.infradead.org
TO: Johannes Berg <johannes.berg@intel.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git ath-next
head:   cd026e68fdbf88b9cc522b76c7a9d92c9a41f709
commit: ef27674b8471b5d1c80fe5ebfaa4f2b07dfb1096 [24/34] wifi: cfg80211: protect wiphy names with cfg80211_mutex
:::::: branch date: 16 hours ago
:::::: commit date: 16 hours ago
config: sparc-randconfig-r2200-20261013 (https://download.01.org/0day-ci/archive/20261014/202610140518.ynVDJha8-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 14.3.0
smatch: v0.5.0-9187-g5189e3fb

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202610140518.ynVDJha8-lkp@intel.com/

New smatch warnings:
net/wireless/nl80211.c:4433 nl80211_set_wiphy() warn: iterator used outside loop: 'wdev'

Old smatch warnings:
net/wireless/nl80211.c:4915 nl80211_send_iface() error: we previously assumed 'rdev->ops->get_channel' could be null (see line 4838)
net/wireless/nl80211.c:9136 nl80211_dump_station() warn: 'wdev' is an error pointer or valid
net/wireless/nl80211.c:9137 nl80211_dump_station() error: 'wdev' dereferencing possible ERR_PTR()
net/wireless/nl80211.c:20272 nl80211_pre_doit() error: 'wdev' dereferencing possible ERR_PTR()

vim +/wdev +4433 net/wireless/nl80211.c

264637941cf45c Roopni Devanathan      2025-06-15  4370  
556829657397b9 Johannes Berg          2007-09-20  4371  static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
556829657397b9 Johannes Berg          2007-09-20  4372  {
a05829a7222e9d Johannes Berg          2021-01-22  4373  	struct cfg80211_registered_device *rdev = NULL;
f444de05d20e27 Johannes Berg          2010-05-05  4374  	struct net_device *netdev = NULL;
ef27674b8471b5 Johannes Berg          2026-10-11  4375  	struct wireless_dev *wdev = NULL;
a1e567c83f5414 Bill Jordan            2010-09-10  4376  	int result = 0, rem_txq_params = 0;
318884875bdddc Jouni Malinen          2008-10-30  4377  	struct nlattr *nl_txq_params;
ef27674b8471b5 Johannes Berg          2026-10-11  4378  	u32 changed, wdev_id = 0;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4379  	u8 retry_short = 0, retry_long = 0;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4380  	u32 frag_threshold = 0, rts_threshold = 0;
81077e82c3f591 Lukáš Turek            2009-12-21  4381  	u8 coverage_class = 0;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4382  	u32 txq_limit = 0, txq_memory_limit = 0, txq_quantum = 0;
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4383  	int radio_idx = -1;
556829657397b9 Johannes Berg          2007-09-20  4384  
ef27674b8471b5 Johannes Berg          2026-10-11  4385  	/* keeps the wiphy registered and its netns stable */
ef27674b8471b5 Johannes Berg          2026-10-11  4386  	mutex_lock(&cfg80211_mutex);
f444de05d20e27 Johannes Berg          2010-05-05  4387  	/*
f444de05d20e27 Johannes Berg          2010-05-05  4388  	 * Try to find the wiphy and netdev. Normally this
f444de05d20e27 Johannes Berg          2010-05-05  4389  	 * function shouldn't need the netdev, but this is
f444de05d20e27 Johannes Berg          2010-05-05  4390  	 * done for backward compatibility -- previously
f444de05d20e27 Johannes Berg          2010-05-05  4391  	 * setting the channel was done per wiphy, but now
f444de05d20e27 Johannes Berg          2010-05-05  4392  	 * it is per netdev. Previous userland like hostapd
f444de05d20e27 Johannes Berg          2010-05-05  4393  	 * also passed a netdev to set_wiphy, so that it is
f444de05d20e27 Johannes Berg          2010-05-05  4394  	 * possible to let that go to the right netdev!
f444de05d20e27 Johannes Berg          2010-05-05  4395  	 */
4bbf4d56583dd5 Johannes Berg          2009-03-24  4396  
f444de05d20e27 Johannes Berg          2010-05-05  4397  	if (info->attrs[NL80211_ATTR_IFINDEX]) {
f444de05d20e27 Johannes Berg          2010-05-05  4398  		int ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]);
f444de05d20e27 Johannes Berg          2010-05-05  4399  
ef27674b8471b5 Johannes Berg          2026-10-11  4400  		rcu_read_lock();
ef27674b8471b5 Johannes Berg          2026-10-11  4401  		netdev = dev_get_by_index_rcu(genl_info_net(info), ifindex);
ef27674b8471b5 Johannes Berg          2026-10-11  4402  		if (netdev && netdev->ieee80211_ptr) {
f26cbf401be935 Zhao, Gang             2014-04-21  4403  			rdev = wiphy_to_rdev(netdev->ieee80211_ptr->wiphy);
ef27674b8471b5 Johannes Berg          2026-10-11  4404  			wdev_id = netdev->ieee80211_ptr->identifier;
ef27674b8471b5 Johannes Berg          2026-10-11  4405  		}
ef27674b8471b5 Johannes Berg          2026-10-11  4406  		rcu_read_unlock();
f444de05d20e27 Johannes Berg          2010-05-05  4407  	}
f444de05d20e27 Johannes Berg          2010-05-05  4408  
ef27674b8471b5 Johannes Berg          2026-10-11  4409  	if (!rdev) {
ef27674b8471b5 Johannes Berg          2026-10-11  4410  		/* RCU for the wdev list walk, cfg80211_mutex keeps rdev */
ef27674b8471b5 Johannes Berg          2026-10-11  4411  		rcu_read_lock();
878d9ec7367816 Johannes Berg          2012-06-15  4412  		rdev = __cfg80211_rdev_from_attrs(genl_info_net(info),
878d9ec7367816 Johannes Berg          2012-06-15  4413  						  info->attrs);
ef27674b8471b5 Johannes Berg          2026-10-11  4414  		rcu_read_unlock();
a05829a7222e9d Johannes Berg          2021-01-22  4415  		if (IS_ERR(rdev)) {
ef27674b8471b5 Johannes Berg          2026-10-11  4416  			mutex_unlock(&cfg80211_mutex);
4c476991062a0a Johannes Berg          2010-10-04  4417  			return PTR_ERR(rdev);
a05829a7222e9d Johannes Berg          2021-01-22  4418  		}
ef27674b8471b5 Johannes Berg          2026-10-11  4419  	}
f444de05d20e27 Johannes Berg          2010-05-05  4420  
f42d22d3f79639 Johannes Berg          2024-11-22  4421  	guard(wiphy)(&rdev->wiphy);
a05829a7222e9d Johannes Berg          2021-01-22  4422  
ef27674b8471b5 Johannes Berg          2026-10-11  4423  	/* the netdev may have been unregistered after the lookup */
ef27674b8471b5 Johannes Berg          2026-10-11  4424  	if (wdev_id) {
ef27674b8471b5 Johannes Berg          2026-10-11  4425  		list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
ef27674b8471b5 Johannes Berg          2026-10-11  4426  			if (wdev->identifier == wdev_id)
ef27674b8471b5 Johannes Berg          2026-10-11  4427  				break;
ef27674b8471b5 Johannes Berg          2026-10-11  4428  		}
ef27674b8471b5 Johannes Berg          2026-10-11  4429  		if (list_entry_is_head(wdev, &rdev->wiphy.wdev_list, list)) {
ef27674b8471b5 Johannes Berg          2026-10-11  4430  			mutex_unlock(&cfg80211_mutex);
ef27674b8471b5 Johannes Berg          2026-10-11  4431  			return -ENODEV;
ef27674b8471b5 Johannes Berg          2026-10-11  4432  		}
ef27674b8471b5 Johannes Berg          2026-10-11 @4433  		netdev = wdev->netdev;
ef27674b8471b5 Johannes Berg          2026-10-11  4434  	} else {
ef27674b8471b5 Johannes Berg          2026-10-11  4435  		netdev = NULL;
ef27674b8471b5 Johannes Berg          2026-10-11  4436  	}
ef27674b8471b5 Johannes Berg          2026-10-11  4437  
f444de05d20e27 Johannes Berg          2010-05-05  4438  	/*
f444de05d20e27 Johannes Berg          2010-05-05  4439  	 * end workaround code, by now the rdev is available
f444de05d20e27 Johannes Berg          2010-05-05  4440  	 * and locked, and wdev may or may not be NULL.
f444de05d20e27 Johannes Berg          2010-05-05  4441  	 */
4bbf4d56583dd5 Johannes Berg          2009-03-24  4442  
4bbf4d56583dd5 Johannes Berg          2009-03-24  4443  	if (info->attrs[NL80211_ATTR_WIPHY_NAME])
318884875bdddc Jouni Malinen          2008-10-30  4444  		result = cfg80211_dev_rename(
318884875bdddc Jouni Malinen          2008-10-30  4445  			rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME]));
ef27674b8471b5 Johannes Berg          2026-10-11  4446  	mutex_unlock(&cfg80211_mutex);
4bbf4d56583dd5 Johannes Berg          2009-03-24  4447  
318884875bdddc Jouni Malinen          2008-10-30  4448  	if (result)
f42d22d3f79639 Johannes Berg          2024-11-22  4449  		return result;
318884875bdddc Jouni Malinen          2008-10-30  4450  
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4451  	if (info->attrs[NL80211_ATTR_WIPHY_RADIO_INDEX]) {
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4452  		/* Radio idx is not expected for non-multi radio wiphy */
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4453  		if (rdev->wiphy.n_radio <= 0)
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4454  			return -EINVAL;
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4455  
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4456  		radio_idx = nla_get_u8(
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4457  				info->attrs[NL80211_ATTR_WIPHY_RADIO_INDEX]);
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4458  		if (radio_idx >= rdev->wiphy.n_radio)
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4459  			return -EINVAL;
264637941cf45c Roopni Devanathan      2025-06-15  4460  
264637941cf45c Roopni Devanathan      2025-06-15  4461  		return nl80211_set_wiphy_radio(info, rdev, radio_idx);
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4462  	}
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4463  
318884875bdddc Jouni Malinen          2008-10-30  4464  	if (info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS]) {
318884875bdddc Jouni Malinen          2008-10-30  4465  		struct ieee80211_txq_params txq_params;
318884875bdddc Jouni Malinen          2008-10-30  4466  		struct nlattr *tb[NL80211_TXQ_ATTR_MAX + 1];
318884875bdddc Jouni Malinen          2008-10-30  4467  
f42d22d3f79639 Johannes Berg          2024-11-22  4468  		if (!rdev->ops->set_txq_params)
f42d22d3f79639 Johannes Berg          2024-11-22  4469  			return -EOPNOTSUPP;
318884875bdddc Jouni Malinen          2008-10-30  4470  
f42d22d3f79639 Johannes Berg          2024-11-22  4471  		if (!netdev)
f42d22d3f79639 Johannes Berg          2024-11-22  4472  			return -EINVAL;
f70f01c2ebbe31 Eliad Peller           2011-09-25  4473  
133a3ff2c93422 Johannes Berg          2011-11-03  4474  		if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
f42d22d3f79639 Johannes Berg          2024-11-22  4475  		    netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
f42d22d3f79639 Johannes Berg          2024-11-22  4476  			return -EINVAL;
133a3ff2c93422 Johannes Berg          2011-11-03  4477  
f42d22d3f79639 Johannes Berg          2024-11-22  4478  		if (!netif_running(netdev))
f42d22d3f79639 Johannes Berg          2024-11-22  4479  			return -ENETDOWN;
2b5f8b0b44e17e Johannes Berg          2012-04-02  4480  
318884875bdddc Jouni Malinen          2008-10-30  4481  		nla_for_each_nested(nl_txq_params,
318884875bdddc Jouni Malinen          2008-10-30  4482  				    info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
318884875bdddc Jouni Malinen          2008-10-30  4483  				    rem_txq_params) {
8cb081746c031f Johannes Berg          2019-04-26  4484  			result = nla_parse_nested_deprecated(tb,
8cb081746c031f Johannes Berg          2019-04-26  4485  							     NL80211_TXQ_ATTR_MAX,
bfe2c7b1cce4a1 Johannes Berg          2016-10-26  4486  							     nl_txq_params,
fe52145f91fe81 Johannes Berg          2017-04-12  4487  							     txq_params_policy,
fe52145f91fe81 Johannes Berg          2017-04-12  4488  							     info->extack);
ae811e21df28de Johannes Berg          2014-01-24  4489  			if (result)
f42d22d3f79639 Johannes Berg          2024-11-22  4490  				return result;
f42d22d3f79639 Johannes Berg          2024-11-22  4491  
318884875bdddc Jouni Malinen          2008-10-30  4492  			result = parse_txq_params(tb, &txq_params);
318884875bdddc Jouni Malinen          2008-10-30  4493  			if (result)
f42d22d3f79639 Johannes Berg          2024-11-22  4494  				return result;
318884875bdddc Jouni Malinen          2008-10-30  4495  
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4496  			txq_params.link_id =
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4497  				nl80211_link_id_or_invalid(info->attrs);
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4498  
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4499  			if (txq_params.link_id >= 0 &&
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4500  			    !(netdev->ieee80211_ptr->valid_links &
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4501  			      BIT(txq_params.link_id)))
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4502  				result = -ENOLINK;
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4503  			else if (txq_params.link_id >= 0 &&
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4504  				 !netdev->ieee80211_ptr->valid_links)
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4505  				result = -EINVAL;
9d2bb84d54a403 Shaul Triebitz         2022-08-02  4506  			else
e35e4d28b687d4 Hila Gonen             2012-06-27  4507  				result = rdev_set_txq_params(rdev, netdev,
318884875bdddc Jouni Malinen          2008-10-30  4508  							     &txq_params);
318884875bdddc Jouni Malinen          2008-10-30  4509  			if (result)
f42d22d3f79639 Johannes Berg          2024-11-22  4510  				return result;
318884875bdddc Jouni Malinen          2008-10-30  4511  		}
318884875bdddc Jouni Malinen          2008-10-30  4512  	}
556829657397b9 Johannes Berg          2007-09-20  4513  
72bdcf34380917 Jouni Malinen          2008-11-26  4514  	if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
69c3f2d30c3576 Ilan Peer              2022-06-12  4515  		int link_id = nl80211_link_id_or_invalid(info->attrs);
69c3f2d30c3576 Ilan Peer              2022-06-12  4516  
4e2f3d67e3afef Johannes Berg          2022-06-20  4517  		if (wdev) {
e16821bcfb364b Jouni Malinen          2014-04-28  4518  			result = __nl80211_set_channel(
e16821bcfb364b Jouni Malinen          2014-04-28  4519  				rdev,
e16821bcfb364b Jouni Malinen          2014-04-28  4520  				nl80211_can_set_dev_channel(wdev) ? netdev : NULL,
69c3f2d30c3576 Ilan Peer              2022-06-12  4521  				info, link_id);
4e2f3d67e3afef Johannes Berg          2022-06-20  4522  		} else {
69c3f2d30c3576 Ilan Peer              2022-06-12  4523  			result = __nl80211_set_channel(rdev, netdev, info, link_id);
4e2f3d67e3afef Johannes Berg          2022-06-20  4524  		}
69c3f2d30c3576 Ilan Peer              2022-06-12  4525  
72bdcf34380917 Jouni Malinen          2008-11-26  4526  		if (result)
f42d22d3f79639 Johannes Berg          2024-11-22  4527  			return result;
72bdcf34380917 Jouni Malinen          2008-11-26  4528  	}
72bdcf34380917 Jouni Malinen          2008-11-26  4529  
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4530  	if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) {
c8442118ad9cd0 Johannes Berg          2012-10-24  4531  		struct wireless_dev *txp_wdev = wdev;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4532  		enum nl80211_tx_power_setting type;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4533  		int idx, mbm = 0;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4534  
c8442118ad9cd0 Johannes Berg          2012-10-24  4535  		if (!(rdev->wiphy.features & NL80211_FEATURE_VIF_TXPOWER))
c8442118ad9cd0 Johannes Berg          2012-10-24  4536  			txp_wdev = NULL;
c8442118ad9cd0 Johannes Berg          2012-10-24  4537  
f42d22d3f79639 Johannes Berg          2024-11-22  4538  		if (!rdev->ops->set_tx_power)
f42d22d3f79639 Johannes Berg          2024-11-22  4539  			return -EOPNOTSUPP;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4540  
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4541  		idx = NL80211_ATTR_WIPHY_TX_POWER_SETTING;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4542  		type = nla_get_u32(info->attrs[idx]);
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4543  
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4544  		if (!info->attrs[NL80211_ATTR_WIPHY_TX_POWER_LEVEL] &&
f42d22d3f79639 Johannes Berg          2024-11-22  4545  		    (type != NL80211_TX_POWER_AUTOMATIC))
f42d22d3f79639 Johannes Berg          2024-11-22  4546  			return -EINVAL;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4547  
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4548  		if (type != NL80211_TX_POWER_AUTOMATIC) {
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4549  			idx = NL80211_ATTR_WIPHY_TX_POWER_LEVEL;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4550  			mbm = nla_get_u32(info->attrs[idx]);
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4551  		}
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4552  
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4553  		result = rdev_set_tx_power(rdev, txp_wdev, radio_idx, type,
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4554  					   mbm);
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4555  		if (result)
f42d22d3f79639 Johannes Berg          2024-11-22  4556  			return result;
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4557  	}
98d2ff8bec82fc Juuso Oikarinen        2010-06-23  4558  
afe0cbf87500f0 Bruno Randolf          2010-11-10  4559  	if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
afe0cbf87500f0 Bruno Randolf          2010-11-10  4560  	    info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
afe0cbf87500f0 Bruno Randolf          2010-11-10  4561  		u32 tx_ant, rx_ant;
7a087e7484c9e4 Kirtika Ruchandani     2016-05-29  4562  
7f531e03abf016 Bruno Randolf          2010-12-16  4563  		if ((!rdev->wiphy.available_antennas_tx &&
7f531e03abf016 Bruno Randolf          2010-12-16  4564  		     !rdev->wiphy.available_antennas_rx) ||
f42d22d3f79639 Johannes Berg          2024-11-22  4565  		    !rdev->ops->set_antenna)
f42d22d3f79639 Johannes Berg          2024-11-22  4566  			return -EOPNOTSUPP;
afe0cbf87500f0 Bruno Randolf          2010-11-10  4567  
afe0cbf87500f0 Bruno Randolf          2010-11-10  4568  		tx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX]);
afe0cbf87500f0 Bruno Randolf          2010-11-10  4569  		rx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);
afe0cbf87500f0 Bruno Randolf          2010-11-10  4570  
a7ffac9591a2a0 Bruno Randolf          2010-12-08  4571  		/* reject antenna configurations which don't match the
7f531e03abf016 Bruno Randolf          2010-12-16  4572  		 * available antenna masks, except for the "all" mask */
7f531e03abf016 Bruno Randolf          2010-12-16  4573  		if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas_tx)) ||
f42d22d3f79639 Johannes Berg          2024-11-22  4574  		    (~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas_rx)))
f42d22d3f79639 Johannes Berg          2024-11-22  4575  			return -EINVAL;
a7ffac9591a2a0 Bruno Randolf          2010-12-08  4576  
7f531e03abf016 Bruno Randolf          2010-12-16  4577  		tx_ant = tx_ant & rdev->wiphy.available_antennas_tx;
7f531e03abf016 Bruno Randolf          2010-12-16  4578  		rx_ant = rx_ant & rdev->wiphy.available_antennas_rx;
a7ffac9591a2a0 Bruno Randolf          2010-12-08  4579  
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4580  		result = rdev_set_antenna(rdev, radio_idx, tx_ant, rx_ant);
afe0cbf87500f0 Bruno Randolf          2010-11-10  4581  		if (result)
f42d22d3f79639 Johannes Berg          2024-11-22  4582  			return result;
afe0cbf87500f0 Bruno Randolf          2010-11-10  4583  	}
afe0cbf87500f0 Bruno Randolf          2010-11-10  4584  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4585  	changed = 0;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4586  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4587  	if (info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4588  		retry_short = nla_get_u8(
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4589  			info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]);
7f2b8562c2ee6e Ying Xue               2014-01-15  4590  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4591  		changed |= WIPHY_PARAM_RETRY_SHORT;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4592  	}
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4593  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4594  	if (info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4595  		retry_long = nla_get_u8(
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4596  			info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]);
7f2b8562c2ee6e Ying Xue               2014-01-15  4597  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4598  		changed |= WIPHY_PARAM_RETRY_LONG;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4599  	}
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4600  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4601  	if (info->attrs[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4602  		frag_threshold = nla_get_u32(
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4603  			info->attrs[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]);
f42d22d3f79639 Johannes Berg          2024-11-22  4604  		if (frag_threshold < 256)
f42d22d3f79639 Johannes Berg          2024-11-22  4605  			return -EINVAL;
7f2b8562c2ee6e Ying Xue               2014-01-15  4606  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4607  		if (frag_threshold != (u32) -1) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4608  			/*
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4609  			 * Fragments (apart from the last one) are required to
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4610  			 * have even length. Make the fragmentation code
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4611  			 * simpler by stripping LSB should someone try to use
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4612  			 * odd threshold value.
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4613  			 */
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4614  			frag_threshold &= ~0x1;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4615  		}
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4616  		changed |= WIPHY_PARAM_FRAG_THRESHOLD;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4617  	}
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4618  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4619  	if (info->attrs[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4620  		rts_threshold = nla_get_u32(
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4621  			info->attrs[NL80211_ATTR_WIPHY_RTS_THRESHOLD]);
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4622  		changed |= WIPHY_PARAM_RTS_THRESHOLD;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4623  	}
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4624  
81077e82c3f591 Lukáš Turek            2009-12-21  4625  	if (info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
f42d22d3f79639 Johannes Berg          2024-11-22  4626  		if (info->attrs[NL80211_ATTR_WIPHY_DYN_ACK])
f42d22d3f79639 Johannes Berg          2024-11-22  4627  			return -EINVAL;
3057dbfdab1b86 Lorenzo Bianconi       2014-09-04  4628  
81077e82c3f591 Lukáš Turek            2009-12-21  4629  		coverage_class = nla_get_u8(
81077e82c3f591 Lukáš Turek            2009-12-21  4630  			info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]);
81077e82c3f591 Lukáš Turek            2009-12-21  4631  		changed |= WIPHY_PARAM_COVERAGE_CLASS;
81077e82c3f591 Lukáš Turek            2009-12-21  4632  	}
81077e82c3f591 Lukáš Turek            2009-12-21  4633  
3057dbfdab1b86 Lorenzo Bianconi       2014-09-04  4634  	if (info->attrs[NL80211_ATTR_WIPHY_DYN_ACK]) {
f42d22d3f79639 Johannes Berg          2024-11-22  4635  		if (!(rdev->wiphy.features & NL80211_FEATURE_ACKTO_ESTIMATION))
f42d22d3f79639 Johannes Berg          2024-11-22  4636  			return -EOPNOTSUPP;
3057dbfdab1b86 Lorenzo Bianconi       2014-09-04  4637  
3057dbfdab1b86 Lorenzo Bianconi       2014-09-04  4638  		changed |= WIPHY_PARAM_DYN_ACK;
81077e82c3f591 Lukáš Turek            2009-12-21  4639  	}
81077e82c3f591 Lukáš Turek            2009-12-21  4640  
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4641  	if (info->attrs[NL80211_ATTR_TXQ_LIMIT]) {
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4642  		if (!wiphy_ext_feature_isset(&rdev->wiphy,
f42d22d3f79639 Johannes Berg          2024-11-22  4643  					     NL80211_EXT_FEATURE_TXQS))
f42d22d3f79639 Johannes Berg          2024-11-22  4644  			return -EOPNOTSUPP;
f42d22d3f79639 Johannes Berg          2024-11-22  4645  
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4646  		txq_limit = nla_get_u32(
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4647  			info->attrs[NL80211_ATTR_TXQ_LIMIT]);
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4648  		changed |= WIPHY_PARAM_TXQ_LIMIT;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4649  	}
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4650  
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4651  	if (info->attrs[NL80211_ATTR_TXQ_MEMORY_LIMIT]) {
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4652  		if (!wiphy_ext_feature_isset(&rdev->wiphy,
f42d22d3f79639 Johannes Berg          2024-11-22  4653  					     NL80211_EXT_FEATURE_TXQS))
f42d22d3f79639 Johannes Berg          2024-11-22  4654  			return -EOPNOTSUPP;
f42d22d3f79639 Johannes Berg          2024-11-22  4655  
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4656  		txq_memory_limit = nla_get_u32(
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4657  			info->attrs[NL80211_ATTR_TXQ_MEMORY_LIMIT]);
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4658  		changed |= WIPHY_PARAM_TXQ_MEMORY_LIMIT;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4659  	}
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4660  
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4661  	if (info->attrs[NL80211_ATTR_TXQ_QUANTUM]) {
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4662  		if (!wiphy_ext_feature_isset(&rdev->wiphy,
f42d22d3f79639 Johannes Berg          2024-11-22  4663  					     NL80211_EXT_FEATURE_TXQS))
f42d22d3f79639 Johannes Berg          2024-11-22  4664  			return -EOPNOTSUPP;
f42d22d3f79639 Johannes Berg          2024-11-22  4665  
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4666  		txq_quantum = nla_get_u32(
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4667  			info->attrs[NL80211_ATTR_TXQ_QUANTUM]);
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4668  		changed |= WIPHY_PARAM_TXQ_QUANTUM;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4669  	}
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4670  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4671  	if (changed) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4672  		u8 old_retry_short, old_retry_long;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4673  		u32 old_frag_threshold, old_rts_threshold;
264637941cf45c Roopni Devanathan      2025-06-15  4674  		u8 old_coverage_class, i;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4675  		u32 old_txq_limit, old_txq_memory_limit, old_txq_quantum;
264637941cf45c Roopni Devanathan      2025-06-15  4676  		u32 *old_radio_rts_threshold = NULL;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4677  
f42d22d3f79639 Johannes Berg          2024-11-22  4678  		if (!rdev->ops->set_wiphy_params)
f42d22d3f79639 Johannes Berg          2024-11-22  4679  			return -EOPNOTSUPP;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4680  
264637941cf45c Roopni Devanathan      2025-06-15  4681  		if (rdev->wiphy.n_radio) {
264637941cf45c Roopni Devanathan      2025-06-15  4682  			old_radio_rts_threshold = kcalloc(rdev->wiphy.n_radio,
264637941cf45c Roopni Devanathan      2025-06-15  4683  							  sizeof(u32),
264637941cf45c Roopni Devanathan      2025-06-15  4684  							  GFP_KERNEL);
264637941cf45c Roopni Devanathan      2025-06-15  4685  			if (!old_radio_rts_threshold)
264637941cf45c Roopni Devanathan      2025-06-15  4686  				return -ENOMEM;
264637941cf45c Roopni Devanathan      2025-06-15  4687  		}
264637941cf45c Roopni Devanathan      2025-06-15  4688  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4689  		old_retry_short = rdev->wiphy.retry_short;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4690  		old_retry_long = rdev->wiphy.retry_long;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4691  		old_frag_threshold = rdev->wiphy.frag_threshold;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4692  		old_rts_threshold = rdev->wiphy.rts_threshold;
264637941cf45c Roopni Devanathan      2025-06-15  4693  		if (old_radio_rts_threshold) {
264637941cf45c Roopni Devanathan      2025-06-15  4694  			for (i = 0 ; i < rdev->wiphy.n_radio; i++)
264637941cf45c Roopni Devanathan      2025-06-15  4695  				old_radio_rts_threshold[i] =
264637941cf45c Roopni Devanathan      2025-06-15  4696  					rdev->wiphy.radio_cfg[i].rts_threshold;
264637941cf45c Roopni Devanathan      2025-06-15  4697  		}
81077e82c3f591 Lukáš Turek            2009-12-21  4698  		old_coverage_class = rdev->wiphy.coverage_class;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4699  		old_txq_limit = rdev->wiphy.txq_limit;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4700  		old_txq_memory_limit = rdev->wiphy.txq_memory_limit;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4701  		old_txq_quantum = rdev->wiphy.txq_quantum;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4702  
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4703  		if (changed & WIPHY_PARAM_RETRY_SHORT)
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4704  			rdev->wiphy.retry_short = retry_short;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4705  		if (changed & WIPHY_PARAM_RETRY_LONG)
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4706  			rdev->wiphy.retry_long = retry_long;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4707  		if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4708  			rdev->wiphy.frag_threshold = frag_threshold;
9eda41e3226380 Stanislaw Gruszka      2026-09-19  4709  		if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4710  			rdev->wiphy.rts_threshold = rts_threshold;
9eda41e3226380 Stanislaw Gruszka      2026-09-19  4711  			if (old_radio_rts_threshold) {
264637941cf45c Roopni Devanathan      2025-06-15  4712  				for (i = 0; i < rdev->wiphy.n_radio; i++)
264637941cf45c Roopni Devanathan      2025-06-15  4713  					rdev->wiphy.radio_cfg[i].rts_threshold =
264637941cf45c Roopni Devanathan      2025-06-15  4714  						rdev->wiphy.rts_threshold;
264637941cf45c Roopni Devanathan      2025-06-15  4715  			}
9eda41e3226380 Stanislaw Gruszka      2026-09-19  4716  		}
81077e82c3f591 Lukáš Turek            2009-12-21  4717  		if (changed & WIPHY_PARAM_COVERAGE_CLASS)
81077e82c3f591 Lukáš Turek            2009-12-21  4718  			rdev->wiphy.coverage_class = coverage_class;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4719  		if (changed & WIPHY_PARAM_TXQ_LIMIT)
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4720  			rdev->wiphy.txq_limit = txq_limit;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4721  		if (changed & WIPHY_PARAM_TXQ_MEMORY_LIMIT)
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4722  			rdev->wiphy.txq_memory_limit = txq_memory_limit;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4723  		if (changed & WIPHY_PARAM_TXQ_QUANTUM)
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4724  			rdev->wiphy.txq_quantum = txq_quantum;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4725  
b74947b4f6ff7c Roopni Devanathan      2025-06-15  4726  		result = rdev_set_wiphy_params(rdev, radio_idx, changed);
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4727  		if (result) {
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4728  			rdev->wiphy.retry_short = old_retry_short;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4729  			rdev->wiphy.retry_long = old_retry_long;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4730  			rdev->wiphy.frag_threshold = old_frag_threshold;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4731  			rdev->wiphy.rts_threshold = old_rts_threshold;
264637941cf45c Roopni Devanathan      2025-06-15  4732  			if (old_radio_rts_threshold) {
264637941cf45c Roopni Devanathan      2025-06-15  4733  				for (i = 0 ; i < rdev->wiphy.n_radio; i++)
264637941cf45c Roopni Devanathan      2025-06-15  4734  					rdev->wiphy.radio_cfg[i].rts_threshold =
264637941cf45c Roopni Devanathan      2025-06-15  4735  						old_radio_rts_threshold[i];
264637941cf45c Roopni Devanathan      2025-06-15  4736  			}
81077e82c3f591 Lukáš Turek            2009-12-21  4737  			rdev->wiphy.coverage_class = old_coverage_class;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4738  			rdev->wiphy.txq_limit = old_txq_limit;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4739  			rdev->wiphy.txq_memory_limit = old_txq_memory_limit;
52539ca89f365d Toke Høiland-Jørgensen 2018-05-08  4740  			rdev->wiphy.txq_quantum = old_txq_quantum;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4741  		}
264637941cf45c Roopni Devanathan      2025-06-15  4742  
264637941cf45c Roopni Devanathan      2025-06-15  4743  		kfree(old_radio_rts_threshold);
264637941cf45c Roopni Devanathan      2025-06-15  4744  		return result;
b9a5f8cab751d3 Jouni Malinen          2009-04-20  4745  	}
a05829a7222e9d Johannes Berg          2021-01-22  4746  
f42d22d3f79639 Johannes Berg          2024-11-22  4747  	return 0;
556829657397b9 Johannes Berg          2007-09-20  4748  }
556829657397b9 Johannes Berg          2007-09-20  4749  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-14  3:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14  3:47 [ath:ath-next 24/34] net/wireless/nl80211.c:4433 nl80211_set_wiphy() warn: iterator used outside loop: 'wdev' kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.