From: Leon Romanovsky <leon@kernel.org>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Kalle Valo <kvalo@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Manikanta Pubbisetty <mpubbise@codeaurora.org>,
ath11k@lists.infradead.org, linux-wireless@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] wifi: ath11k: Fix memory leak in ath11k_peer_rx_frag_setup
Date: Sun, 1 Jan 2023 09:44:46 +0200 [thread overview]
Message-ID: <Y7E57sQ9LiJWefoj@unreal> (raw)
In-Reply-To: <20221229073849.1388315-1-linmq006@gmail.com>
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@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
>
prev parent reply other threads:[~2023-01-01 7:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-29 7:38 [PATCH] wifi: ath11k: Fix memory leak in ath11k_peer_rx_frag_setup Miaoqian Lin
2023-01-01 7:44 ` Leon Romanovsky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y7E57sQ9LiJWefoj@unreal \
--to=leon@kernel.org \
--cc=ath11k@lists.infradead.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mpubbise@codeaurora.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).