mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH ath-next] wifi: ath10k: free msdu_id and skb reference when HL TX fails
@ 2026-11-18  5:21 Changyul Lee
  2026-11-18  8:53 ` Loic Poulain
  0 siblings, 1 reply; 4+ messages in thread
From: Changyul Lee @ 2026-11-18  5:21 UTC (permalink / raw)
  To: Jeff Johnson, Loic Poulain
  Cc: Wentao Liang, linux-wireless, ath10k, linux-kernel, Changyul Lee

For SDIO and USB devices, ath10k_htt_tx_hl() allocates an msdu_id in
htt->pending_tx and takes an extra skb reference that
ath10k_htt_htc_tx_complete() normally drops. If ath10k_htc_send_hl()
fails, for example because the endpoint has no TX credits and TX
bundling is off, no completion runs and both are leaked. After
max_num_pending_tx such failures, msdu_id allocation fails and no more
data frames can be sent.

Free the msdu_id under tx_lock, as ath10k_htt_tx_32() does on its error
path, and drop the extra skb reference.

Fixes: 8ea51e409eb0 ("ath10k: htt: support MSDU ids with SDIO")
Fixes: 30382dd1cf3a ("ath10k: fix use-after-free on SDIO data frames")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
---
Found with a static analysis tool we are developing.

Compile-tested only, with x86_64_defconfig plus ATH10K_SDIO, ATH10K_USB
and W=1.

 drivers/net/wireless/ath/ath10k/htt_tx.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index efaea150025b..b437b09717e1 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -1378,6 +1378,14 @@ static int ath10k_htt_tx_hl(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txm
 	tx_desc->peerid = __cpu_to_le32(HTT_INVALID_PEERID);
 
 	res = ath10k_htc_send_hl(&htt->ar->htc, htt->eid, msdu);
+	if (res) {
+		if (ar->bus_param.hl_msdu_ids) {
+			spin_lock_bh(&htt->tx_lock);
+			ath10k_htt_tx_free_msdu_id(htt, msdu_id);
+			spin_unlock_bh(&htt->tx_lock);
+		}
+		dev_kfree_skb_any(msdu);
+	}
 
 out:
 	return res;

base-commit: 4016f6c3149e7e3faccc1654db6a3030c069383a
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH ath-next] wifi: ath10k: free msdu_id and skb reference when HL TX fails
  2026-11-18  5:21 [PATCH ath-next] wifi: ath10k: free msdu_id and skb reference when HL TX fails Changyul Lee
@ 2026-11-18  8:53 ` Loic Poulain
  2026-11-18 21:56   ` Changyul Lee
  0 siblings, 1 reply; 4+ messages in thread
From: Loic Poulain @ 2026-11-18  8:53 UTC (permalink / raw)
  To: Changyul Lee
  Cc: Jeff Johnson, Wentao Liang, linux-wireless, ath10k, linux-kernel

On Wed, Nov 18, 2026 at 6:21 AM Changyul Lee <lcy8047@gmail.com> wrote:
>
> For SDIO and USB devices, ath10k_htt_tx_hl() allocates an msdu_id in
> htt->pending_tx and takes an extra skb reference that
> ath10k_htt_htc_tx_complete() normally drops. If ath10k_htc_send_hl()
> fails, for example because the endpoint has no TX credits and TX
> bundling is off, no completion runs and both are leaked. After
> max_num_pending_tx such failures, msdu_id allocation fails and no more
> data frames can be sent.

The above message looks too verbose and confusing for a somewhat
simple issue. Maybe this should be split properly in two fixes.

> Free the msdu_id under tx_lock, as ath10k_htt_tx_32() does on its error
> path, and drop the extra skb reference.
>
> Fixes: 8ea51e409eb0 ("ath10k: htt: support MSDU ids with SDIO")
> Fixes: 30382dd1cf3a ("ath10k: fix use-after-free on SDIO data frames")

If this is a fix you should not target 'ath-next'.
Two fixes tag looks weird, what are you fixin exactly?


> Signed-off-by: Changyul Lee <lcy8047@gmail.com>
> ---
> Found with a static analysis tool we are developing.
>
> Compile-tested only, with x86_64_defconfig plus ATH10K_SDIO, ATH10K_USB
> and W=1.
>
>  drivers/net/wireless/ath/ath10k/htt_tx.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
> index efaea150025b..b437b09717e1 100644
> --- a/drivers/net/wireless/ath/ath10k/htt_tx.c
> +++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
> @@ -1378,6 +1378,14 @@ static int ath10k_htt_tx_hl(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txm
>         tx_desc->peerid = __cpu_to_le32(HTT_INVALID_PEERID);
>
>         res = ath10k_htc_send_hl(&htt->ar->htc, htt->eid, msdu);
> +       if (res) {
> +               if (ar->bus_param.hl_msdu_ids) {
> +                       spin_lock_bh(&htt->tx_lock);
> +                       ath10k_htt_tx_free_msdu_id(htt, msdu_id);
> +                       spin_unlock_bh(&htt->tx_lock);
> +               }
> +               dev_kfree_skb_any(msdu);
> +       }
>
>  out:
>         return res;
>
> base-commit: 4016f6c3149e7e3faccc1654db6a3030c069383a
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH ath-next] wifi: ath10k: free msdu_id and skb reference when HL TX fails
  2026-11-18  8:53 ` Loic Poulain
@ 2026-11-18 21:56   ` Changyul Lee
  2026-11-18 23:09     ` Jeff Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Changyul Lee @ 2026-11-18 21:56 UTC (permalink / raw)
  To: Loic Poulain
  Cc: Jeff Johnson, Wentao Liang, linux-wireless, ath10k, linux-kernel

Hi Loic,

Thanks for the review.

On Wed, Nov 18, 2026 at 9:53 AM Loic Poulain wrote:
> The above message looks too verbose and confusing for a somewhat
> simple issue. Maybe this should be split properly in two fixes.

I originally wanted to fix the msdu_id leak. ath10k_htt_tx_hl()
allocates an msdu_id in htt->pending_tx, but leaves the entry there
if ath10k_htc_send_hl() fails.

I also noticed that the same error path doesn't drop the extra skb
reference taken by skb_get(), so I included both fixes in v1. I think
I could have explained this more clearly when covering both fixes
together. Sorry for the confusion.

> If this is a fix you should not target 'ath-next'.
> Two fixes tag looks weird, what are you fixin exactly?

I Cc'd Wentao Liang because he had already posted a patch for the skb
reference leak [1], but I left that explanation out of v1. Would it be
okay if I sent a v2 that only fixes the msdu_id leak?

[1] https://lore.kernel.org/all/20260917120112.2150211-1-vulab@iscas.ac.cn/

Thanks,
Changyul

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH ath-next] wifi: ath10k: free msdu_id and skb reference when HL TX fails
  2026-11-18 21:56   ` Changyul Lee
@ 2026-11-18 23:09     ` Jeff Johnson
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Johnson @ 2026-11-18 23:09 UTC (permalink / raw)
  To: Changyul Lee, Loic Poulain
  Cc: Jeff Johnson, Wentao Liang, linux-wireless, ath10k, linux-kernel

On 11/18/2026 1:56 PM, Changyul Lee wrote:
> Hi Loic,
> 
> Thanks for the review.
> 
> On Wed, Nov 18, 2026 at 9:53 AM Loic Poulain wrote:
>> The above message looks too verbose and confusing for a somewhat
>> simple issue. Maybe this should be split properly in two fixes.
> 
> I originally wanted to fix the msdu_id leak. ath10k_htt_tx_hl()
> allocates an msdu_id in htt->pending_tx, but leaves the entry there
> if ath10k_htc_send_hl() fails.
> 
> I also noticed that the same error path doesn't drop the extra skb
> reference taken by skb_get(), so I included both fixes in v1. I think
> I could have explained this more clearly when covering both fixes
> together. Sorry for the confusion.
> 
>> If this is a fix you should not target 'ath-next'.
>> Two fixes tag looks weird, what are you fixin exactly?
> 
> I Cc'd Wentao Liang because he had already posted a patch for the skb
> reference leak [1], but I left that explanation out of v1. Would it be
> okay if I sent a v2 that only fixes the msdu_id leak?
> 
> [1] https://lore.kernel.org/all/20260917120112.2150211-1-vulab@iscas.ac.cn/
FWIW I've rejected all patches from vulab@iscas.ac.cn since multiple folks
were using the same e-mail address which is contrary to the DCO. So I'm
waiting to see if there is a repost with an individualized e-mail address.

But I also don't want multiple fixes in a single patch because then it
complicates backporting to stable kernels (unless both of the patches being
fixed were originally part of the same kernel or both predate v5.10).

/jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-18 23:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18  5:21 [PATCH ath-next] wifi: ath10k: free msdu_id and skb reference when HL TX fails Changyul Lee
2026-11-18  8:53 ` Loic Poulain
2026-11-18 21:56   ` Changyul Lee
2026-11-18 23:09     ` Jeff Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®