Commit ad969bc9 authored by Kalle Valo's avatar Kalle Valo
Browse files

wifi: ath12k: ath12k_mac_op_set_key(): fix uninitialized symbol 'ret'



Dan reported that in some cases the ret variable could be uninitialized. Fix
that by removing the out label entirely and returning zero explicitly on
succesful cases.

Also remove the unnecessary else branches to follow more the style used in
ath12k and now it's easier to see the error handling.

No functional changes.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/7e7afd00-ad84-4744-8d94-416bab7e7dd9@stanley.mountain/


Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://patch.msgid.link/20241126171139.2350704-10-kvalo@kernel.org
parent aa80f12f
Loading
Loading
Loading
Loading
+32 −25
Original line number Diff line number Diff line
@@ -4657,6 +4657,7 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,

	if (sta) {
		ahsta = ath12k_sta_to_ahsta(sta);

		/* For an ML STA Pairwise key is same for all associated link Stations,
		 * hence do set key for all link STAs which are active.
		 */
@@ -4679,17 +4680,22 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
				if (ret)
					break;
			}
		} else {

			return 0;
		}

		arsta = &ahsta->deflink;
		arvif = arsta->arvif;
			if (WARN_ON(!arvif)) {
				ret = -EINVAL;
				goto out;
			}
		if (WARN_ON(!arvif))
			return -EINVAL;

		ret = ath12k_mac_set_key(arvif->ar, cmd, arvif, arsta, key);
		if (ret)
			return ret;

		return 0;
	}
	} else {

	if (key->link_id >= 0 && key->link_id < IEEE80211_MLD_MAX_NUM_LINKS) {
		link_id = key->link_id;
		arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]);
@@ -4704,16 +4710,17 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
			return -ENOSPC;

		ret = ath12k_mac_update_key_cache(cache, cmd, sta, key);

		if (ret)
			return ret;
		}

		ret = ath12k_mac_set_key(arvif->ar, cmd, arvif, NULL, key);
		return 0;
	}

out:

	ret = ath12k_mac_set_key(arvif->ar, cmd, arvif, NULL, key);
	if (ret)
		return ret;

	return 0;
}

static int