rtl818x: fix potential use after free
authorPan Bian <bianpan2016@163.com>
Thu, 29 Nov 2018 10:48:10 +0000 (18:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2019 14:37:18 +0000 (15:37 +0100)
[ Upstream commit afbb1947db94eacc5a13302eee88a9772fb78935 ]

entry is released via usb_put_urb just after calling usb_submit_urb.
However, entry is used if the submission fails, resulting in a use after
free bug. The patch fixes this.

Signed-off-by: Pan Bian <bianpan2016@163.com>
ACKed-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c

index 9a1d15b3ce4535540184d34a5600be131ba329dd..518caaaf8a98765647b81cbc4f099f29d7a1534b 100644 (file)
@@ -444,12 +444,13 @@ static int rtl8187_init_urbs(struct ieee80211_hw *dev)
                skb_queue_tail(&priv->rx_queue, skb);
                usb_anchor_urb(entry, &priv->anchored);
                ret = usb_submit_urb(entry, GFP_KERNEL);
-               usb_put_urb(entry);
                if (ret) {
                        skb_unlink(skb, &priv->rx_queue);
                        usb_unanchor_urb(entry);
+                       usb_put_urb(entry);
                        goto err;
                }
+               usb_put_urb(entry);
        }
        return ret;