[ath:ath12k-mlo 34/63] drivers/net/wireless/ath/ath12k/mac.c:4289:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is true

kernel test robot lkp at intel.com
Sun Sep 15 01:57:47 PDT 2024


tree:   https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git ath12k-mlo
head:   8f61af03fddc0a30bdf49e06a13eafff3cec91b0
commit: ec3755e39b7ae8f7ed9853e6169fa5e307b9fb90 [34/63] wifi: ath12k: modify ath12k_mac_op_set_key for MLO
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20240915/202409151616.hnCxh90B-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240915/202409151616.hnCxh90B-lkp@intel.com/reproduce)

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 at intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409151616.hnCxh90B-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath12k/mac.c:4289:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    4289 |                         if (WARN_ON(!arvif))
         |                             ^~~~~~~~~~~~~~~
   include/asm-generic/bug.h:122:28: note: expanded from macro 'WARN_ON'
     122 | #define WARN_ON(condition) ({                                           \
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     123 |         int __ret_warn_on = !!(condition);                              \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     124 |         if (unlikely(__ret_warn_on))                                    \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     125 |                 __WARN();                                               \
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     126 |         unlikely(__ret_warn_on);                                        \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     127 | })
         | ~~
   drivers/net/wireless/ath/ath12k/mac.c:4322:9: note: uninitialized use occurs here
    4322 |         return ret;
         |                ^~~
   drivers/net/wireless/ath/ath12k/mac.c:4289:4: note: remove the 'if' if its condition is always false
    4289 |                         if (WARN_ON(!arvif))
         |                         ^~~~~~~~~~~~~~~~~~~~
    4290 |                                 goto out;
         |                                 ~~~~~~~~
   drivers/net/wireless/ath/ath12k/mac.c:4245:9: note: initialize the variable 'ret' to silence this warning
    4245 |         int ret;
         |                ^
         |                 = 0
   1 warning generated.


vim +4289 drivers/net/wireless/ath/ath12k/mac.c

  4232	
  4233	static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  4234					 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  4235					 struct ieee80211_key_conf *key)
  4236	{
  4237		struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
  4238		struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
  4239		struct ath12k_link_vif *arvif;
  4240		struct ath12k_link_sta *arsta = NULL;
  4241		struct ath12k_vif_cache *cache;
  4242		struct ath12k_sta *ahsta;
  4243		unsigned long links;
  4244		u8 link_id;
  4245		int ret;
  4246	
  4247		mutex_lock(&ah->conf_mutex);
  4248		/* BIP needs to be done in software */
  4249		if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
  4250		    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
  4251		    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
  4252		    key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256) {
  4253			mutex_unlock(&ah->conf_mutex);
  4254			return 1;
  4255		}
  4256	
  4257		if (key->keyidx > WMI_MAX_KEY_INDEX) {
  4258			mutex_unlock(&ah->conf_mutex);
  4259			return -ENOSPC;
  4260		}
  4261	
  4262		if (sta) {
  4263			ahsta = ath12k_sta_to_ahsta(sta);
  4264			/* For an ML STA Pairwise key is same for all associated link Stations,
  4265			 * hence do set key for all link STAs.
  4266			 */
  4267			if (sta->mlo) {
  4268				links = sta->valid_links;
  4269				for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) {
  4270					arvif = rcu_dereference_protected(ahvif->link[link_id],
  4271							lockdep_is_held(&ah->conf_mutex));
  4272					arsta = rcu_dereference_protected(ahsta->link[link_id],
  4273							lockdep_is_held(&ah->conf_mutex));
  4274					/* arvif and arsta are expected to be valid when
  4275					 * STA is present.
  4276					 */
  4277					if (WARN_ON(!arvif || !arsta))
  4278						continue;
  4279					mutex_lock(&arvif->ar->conf_mutex);
  4280					ret = ath12k_mac_set_key(arvif->ar, cmd, arvif,
  4281								 arsta, key);
  4282					mutex_unlock(&arvif->ar->conf_mutex);
  4283					if (ret)
  4284						break;
  4285				}
  4286			} else {
  4287				arsta = &ahsta->deflink;
  4288				arvif = arsta->arvif;
> 4289				if (WARN_ON(!arvif))
  4290					goto out;
  4291				mutex_lock(&arvif->ar->conf_mutex);
  4292				ret = ath12k_mac_set_key(arvif->ar, cmd, arvif, arsta, key);
  4293				mutex_unlock(&arvif->ar->conf_mutex);
  4294			}
  4295		} else {
  4296			if (key->link_id >= 0 && key->link_id < IEEE80211_MLD_MAX_NUM_LINKS) {
  4297				link_id = key->link_id;
  4298				arvif = rcu_dereference_protected(ahvif->link[link_id],
  4299						lockdep_is_held(&ah->conf_mutex));
  4300			} else {
  4301				link_id = 0;
  4302				arvif = &ahvif->deflink;
  4303			}
  4304	
  4305			if (!arvif || !arvif->is_created) {
  4306				cache = ath12k_ahvif_get_link_cache(ahvif, link_id);
  4307				if (!cache) {
  4308					mutex_unlock(&ah->conf_mutex);
  4309					return -ENOSPC;
  4310				}
  4311				ret = ath12k_mac_update_key_cache(cache, cmd, sta, key);
  4312				mutex_unlock(&ah->conf_mutex);
  4313				return ret;
  4314			}
  4315	
  4316			mutex_lock(&arvif->ar->conf_mutex);
  4317			ret = ath12k_mac_set_key(arvif->ar, cmd, arvif, NULL, key);
  4318			mutex_unlock(&arvif->ar->conf_mutex);
  4319		}
  4320	out:
  4321		mutex_unlock(&ah->conf_mutex);
  4322		return ret;
  4323	}
  4324	

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



More information about the ath12k mailing list