]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: usb: fix leak in rtw89_usb_write_port()
authorFedor Pchelkin <pchelkin@ispras.ru>
Tue, 4 Nov 2025 13:57:09 +0000 (16:57 +0300)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 6 Nov 2025 06:28:25 +0000 (14:28 +0800)
When there is an attempt to write data and RTW89_FLAG_UNPLUGGED is set,
this means device is disconnected and no urb is submitted.  Return
appropriate error code to the caller to properly free the allocated
resources.

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-3-pchelkin@ispras.ru
drivers/net/wireless/realtek/rtw89/usb.c

index 450631c77840b3e8d629d218db445fcd94621000..639b84ebe9423bdc193a31dae6ebc04a8bc7c369 100644 (file)
@@ -236,7 +236,7 @@ static int rtw89_usb_write_port(struct rtw89_dev *rtwdev, u8 ch_dma,
        int ret;
 
        if (test_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags))
-               return 0;
+               return -ENODEV;
 
        urb = usb_alloc_urb(0, GFP_ATOMIC);
        if (!urb)
@@ -285,8 +285,9 @@ static void rtw89_usb_ops_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)
                ret = rtw89_usb_write_port(rtwdev, txch, skb->data, skb->len,
                                           txcb);
                if (ret) {
-                       rtw89_err(rtwdev, "write port txch %d failed: %d\n",
-                                 txch, ret);
+                       if (ret != -ENODEV)
+                               rtw89_err(rtwdev, "write port txch %d failed: %d\n",
+                                         txch, ret);
 
                        skb_dequeue(&txcb->tx_ack_queue);
                        kfree(txcb);