[PATCH 1/5] wifi: ath11k: refactor transmitted arvif retrieval

Sidhanta Sahu quic_sidhanta at quicinc.com
Wed Jan 15 11:36:04 PST 2025


>   
> +static struct ath11k_vif *ath11k_mac_get_tx_arvif(struct ath11k_vif *arvif)
> +{
> +	if (arvif->vif->mbssid_tx_vif)
> +		return ath11k_vif_to_arvif(arvif->vif->mbssid_tx_vif);
> +
> +	return NULL;
> +}
> +
>   static int ath11k_mac_setup_bcn_tmpl_ema(struct ath11k_vif *arvif)
>   {
>   	struct ath11k_vif *tx_arvif;
> @@ -1538,7 +1546,7 @@ static int ath11k_mac_setup_bcn_tmpl_ema(struct ath11k_vif *arvif)
>   	u32 params = 0;
>   	u8 i = 0;
>   
> -	tx_arvif = ath11k_vif_to_arvif(arvif->vif->mbssid_tx_vif);
> +	tx_arvif = ath11k_mac_get_tx_arvif(arvif);

ath11k_mac_get_tx_arvif can return NULL, below, we are accessing 
tx_arvif without a NULL check. Shouldn't we add a null check wherever 
applicable to prevent potential issues?

>   
>   	beacons = ieee80211_beacon_get_template_ema_list(tx_arvif->ar->hw,
>   							 tx_arvif->vif, 0);
> @@ -1597,7 +1605,7 @@ static int ath11k_mac_setup_bcn_tmpl_mbssid(struct ath11k_vif *arvif)
>   	int ret;
>   
>   	if (vif->mbssid_tx_vif) {
> -		tx_arvif = ath11k_vif_to_arvif(vif->mbssid_tx_vif);
> +		tx_arvif = ath11k_mac_get_tx_arvif(arvif);
>   		if (tx_arvif != arvif) {
>   			ar = tx_arvif->ar;
>   			ab = ar->ab;
> @@ -1674,7 +1682,7 @@ static void ath11k_control_beaconing(struct ath11k_vif *arvif,
>   				     struct ieee80211_bss_conf *info)
>   {
>   	struct ath11k *ar = arvif->ar;
> -	struct ath11k_vif *tx_arvif = NULL;
> +	struct ath11k_vif *tx_arvif;
>   	int ret = 0;
>   
>   	lockdep_assert_held(&arvif->ar->conf_mutex);
> @@ -1701,9 +1709,7 @@ static void ath11k_control_beaconing(struct ath11k_vif *arvif,
>   
>   	ether_addr_copy(arvif->bssid, info->bssid);
>   
> -	if (arvif->vif->mbssid_tx_vif)
> -		tx_arvif = ath11k_vif_to_arvif(arvif->vif->mbssid_tx_vif);
> -
> +	tx_arvif = ath11k_mac_get_tx_arvif(arvif);
>   	ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
>   				 arvif->bssid,
>   				 tx_arvif ? tx_arvif->bssid : NULL,
> @@ -6333,14 +6339,12 @@ static int ath11k_mac_setup_vdev_params_mbssid(struct ath11k_vif *arvif,
>   	struct ieee80211_vif *tx_vif;
>   
>   	*tx_vdev_id = 0;
> -	tx_vif = arvif->vif->mbssid_tx_vif;
> -	if (!tx_vif) {
> +	tx_arvif = ath11k_mac_get_tx_arvif(arvif);
> +	if (!tx_arvif) {
>   		*flags = WMI_HOST_VDEV_FLAGS_NON_MBSSID_AP;
>   		return 0;
>   	}
>   
> -	tx_arvif = ath11k_vif_to_arvif(tx_vif);
> -
>   	if (arvif->vif->bss_conf.nontransmitted) {
>   		if (ar->hw->wiphy != ieee80211_vif_to_wdev(tx_vif)->wiphy)
>   			return -EINVAL;
> @@ -7306,8 +7310,7 @@ ath11k_mac_update_vif_chan(struct ath11k *ar,
>   			   int n_vifs)
>   {
>   	struct ath11k_base *ab = ar->ab;
> -	struct ath11k_vif *arvif, *tx_arvif = NULL;
> -	struct ieee80211_vif *mbssid_tx_vif;
> +	struct ath11k_vif *arvif, *tx_arvif;
>   	int ret;
>   	int i;
>   	bool monitor_vif = false;
> @@ -7361,10 +7364,7 @@ ath11k_mac_update_vif_chan(struct ath11k *ar,
>   			ath11k_warn(ab, "failed to update bcn tmpl during csa: %d\n",
>   				    ret);
>   
> -		mbssid_tx_vif = arvif->vif->mbssid_tx_vif;
> -		if (mbssid_tx_vif)
> -			tx_arvif = ath11k_vif_to_arvif(mbssid_tx_vif);
> -
> +		tx_arvif = ath11k_mac_get_tx_arvif(arvif);
>   		ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
>   					 arvif->bssid,
>   					 tx_arvif ? tx_arvif->bssid : NULL,



More information about the ath11k mailing list