[PATCH] wifi: ath11k: Fix memory leak in ath11k_peer_rx_frag_setup

Leon Romanovsky leon at kernel.org
Sat Dec 31 23:44:46 PST 2022


On Thu, Dec 29, 2022 at 11:38:48AM +0400, Miaoqian Lin wrote:
> crypto_alloc_shash() allocates resources, which should be released by
> crypto_free_shash(). When ath11k_peer_find() fails, there has memory
> leak. Move crypto_alloc_shash() after ath11k_peer_find() to fix this.
> 
> Fixes: 243874c64c81 ("ath11k: handle RX fragments")
> Signed-off-by: Miaoqian Lin <linmq006 at gmail.com>
> ---
>  drivers/net/wireless/ath/ath11k/dp_rx.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
> index c5a4c34d7749..1297caa2b09a 100644
> --- a/drivers/net/wireless/ath/ath11k/dp_rx.c
> +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
> @@ -3116,10 +3116,6 @@ int ath11k_peer_rx_frag_setup(struct ath11k *ar, const u8 *peer_mac, int vdev_id
>  	struct dp_rx_tid *rx_tid;
>  	int i;
>  
> -	tfm = crypto_alloc_shash("michael_mic", 0, 0);
> -	if (IS_ERR(tfm))
> -		return PTR_ERR(tfm);
> -
>  	spin_lock_bh(&ab->base_lock);
>  
>  	peer = ath11k_peer_find(ab, vdev_id, peer_mac);
> @@ -3129,6 +3125,10 @@ int ath11k_peer_rx_frag_setup(struct ath11k *ar, const u8 *peer_mac, int vdev_id
>  		return -ENOENT;
>  	}
>  
> +	tfm = crypto_alloc_shash("michael_mic", 0, 0);
> +	if (IS_ERR(tfm))
> +		return PTR_ERR(tfm);
> +

You forgot to unlock ab->base_lock.

Thanks

>  	for (i = 0; i <= IEEE80211_NUM_TIDS; i++) {
>  		rx_tid = &peer->rx_tid[i];
>  		rx_tid->ab = ab;
> -- 
> 2.25.1
> 



More information about the ath11k mailing list