]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: rtw89: usb: use common error path for skbs in rtw89_usb_rx_handler()
authorFedor Pchelkin <pchelkin@ispras.ru>
Tue, 4 Nov 2025 13:57:08 +0000 (16:57 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:51 +0000 (14:02 +0100)
[ Upstream commit 28a45575289f3292aa9cb7bacae18ba3ee7a6adf ]

Allow adding rx_skb to rx_free_queue for later reuse on the common error
handling path, otherwise free it.

Found by Linux Verification Center (linuxtesting.org).

Fixes: 2135c28be6a8 ("wifi: rtw89: Add usb.{c,h}")
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20251104135720.321110-2-pchelkin@ispras.ru
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/realtek/rtw89/usb.c

index 6cf89aee252edaa7b916ab6b6f71e3c761682927..e8e064cf7e0ad9244c3413d6069ab76f5f5925a7 100644 (file)
@@ -410,8 +410,7 @@ static void rtw89_usb_rx_handler(struct work_struct *work)
 
                if (skb_queue_len(&rtwusb->rx_queue) >= RTW89_USB_MAX_RXQ_LEN) {
                        rtw89_warn(rtwdev, "rx_queue overflow\n");
-                       dev_kfree_skb_any(rx_skb);
-                       continue;
+                       goto free_or_reuse;
                }
 
                memset(&desc_info, 0, sizeof(desc_info));
@@ -422,7 +421,7 @@ static void rtw89_usb_rx_handler(struct work_struct *work)
                        rtw89_debug(rtwdev, RTW89_DBG_HCI,
                                    "failed to allocate RX skb of size %u\n",
                                    desc_info.pkt_size);
-                       continue;
+                       goto free_or_reuse;
                }
 
                pkt_offset = desc_info.offset + desc_info.rxd_len;
@@ -432,6 +431,7 @@ static void rtw89_usb_rx_handler(struct work_struct *work)
 
                rtw89_core_rx(rtwdev, &desc_info, skb);
 
+free_or_reuse:
                if (skb_queue_len(&rtwusb->rx_free_queue) >= RTW89_USB_RX_SKB_NUM)
                        dev_kfree_skb_any(rx_skb);
                else