All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zong-Zhe Yang <kevin_yang@realtek.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>, Ping-Ke Shih <pkshih@realtek.com>
Cc: Bernie Huang <phhuang@realtek.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: RE: [PATCH rtw v2 3/4] wifi: rtw89: fix leak in rtw89_core_send_nullfunc()
Date: Thu, 28 Aug 2025 08:25:40 +0000	[thread overview]
Message-ID: <e40bc0798fdb48c7919d3954803a7751@realtek.com> (raw)
In-Reply-To: <20250827120603.723548-4-pchelkin@ispras.ru>

Fedor Pchelkin <pchelkin@ispras.ru> wrote:
> If there is no rtwsta_link found in rtw89_core_send_nullfunc(), allocated skb is leaked.  Free
> it on the error handling path.
> 
> Found by Linux Verification Center (linuxtesting.org).
> 
> Fixes: a8ba4acab7db ("wifi: rtw89: send nullfunc based on the given link")
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
> ---
>  drivers/net/wireless/realtek/rtw89/core.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/core.c
> b/drivers/net/wireless/realtek/rtw89/core.c
> index 28bbc898b95e..e498c08151d5 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.c
> +++ b/drivers/net/wireless/realtek/rtw89/core.c
> @@ -3454,14 +3454,14 @@ int rtw89_core_send_nullfunc(struct rtw89_dev *rtwdev, struct
> rtw89_vif_link *rt
>         sta = ieee80211_find_sta(vif, vif->cfg.ap_addr);
>         if (!sta) {
>                 ret = -EINVAL;
> -               goto out;
> +               goto out_unlock;
>         }
>         rtwsta = sta_to_rtwsta(sta);
> 
>         skb = ieee80211_nullfunc_get(rtwdev->hw, vif, link_id, qos);
>         if (!skb) {
>                 ret = -ENOMEM;
> -               goto out;
> +               goto out_unlock;
>         }
> 
>         hdr = (struct ieee80211_hdr *)skb->data; @@ -3471,22 +3471,23 @@ int
> rtw89_core_send_nullfunc(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rt
>         rtwsta_link = rtwsta->links[rtwvif_link->link_id];
>         if (unlikely(!rtwsta_link)) {
>                 ret = -ENOLINK;
> -               goto out;
> +               goto out_free_skb;
>         }

How about just adding dev_kfree_skb_any(skb) here ?

> 
>         ret = rtw89_core_tx_write_link(rtwdev, rtwvif_link, rtwsta_link, skb, &qsel, true,
>                                        wait);
>         if (ret) {
>                 rtw89_warn(rtwdev, "nullfunc transmit failed: %d\n", ret);
> -               dev_kfree_skb_any(skb);
> -               goto out;
> +               goto out_free_skb;
>         }
> 
>         rcu_read_unlock();
> 
>         return rtw89_core_tx_kick_off_and_wait(rtwdev, skb, qsel,
>                                                timeout);
> -out:
> +out_free_skb:
> +       dev_kfree_skb_any(skb);
> +out_unlock:
>         rcu_read_unlock();
>         kfree(wait);
> 
> --
> 2.50.1
> 


  reply	other threads:[~2025-08-28  8:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 12:05 [PATCH rtw v2 0/4] fixes for rtw89 Fedor Pchelkin
2025-08-27 12:05 ` [PATCH rtw v2 1/4] wifi: rtw89: fix use-after-free in rtw89_core_tx_kick_off_and_wait() Fedor Pchelkin
2025-08-28  8:07   ` Zong-Zhe Yang
2025-08-28 11:35     ` pchelkin
2025-08-29  3:02       ` Zong-Zhe Yang
2025-08-27 12:05 ` [PATCH rtw v2 2/4] wifi: rtw89: fix tx_wait initialization race Fedor Pchelkin
2025-08-27 12:05 ` [PATCH rtw v2 3/4] wifi: rtw89: fix leak in rtw89_core_send_nullfunc() Fedor Pchelkin
2025-08-28  8:25   ` Zong-Zhe Yang [this message]
2025-08-27 12:05 ` [PATCH rtw v2 4/4] wifi: rtw89: avoid circular locking dependency in ser_state_run() Fedor Pchelkin

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=e40bc0798fdb48c7919d3954803a7751@realtek.com \
    --to=kevin_yang@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=pchelkin@ispras.ru \
    --cc=phhuang@realtek.com \
    --cc=pkshih@realtek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.