diff mbox series

rtl818x: fix potential use after free

Message ID 1543488490-101743-1-git-send-email-bianpan2016@163.com (mailing list archive)
State Accepted
Commit afbb1947db94eacc5a13302eee88a9772fb78935
Delegated to: Kalle Valo
Headers show
Series rtl818x: fix potential use after free | expand

Commit Message

Pan Bian Nov. 29, 2018, 10:48 a.m. UTC
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>
---
 drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Larry Finger Nov. 29, 2018, 3:09 p.m. UTC | #1
On 11/29/18 4:48 AM, Pan Bian wrote:
> 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>
> ---
>   drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
> index cec3778..1a2ea8b 100644
> --- a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
> +++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
> @@ -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;

Good catch.

ACKed-by: Larry Finger <Larry.Finger@lwfinger.net>

Thanks,
Larry
Kalle Valo Dec. 13, 2018, 3:03 p.m. UTC | #2
Pan Bian <bianpan2016@163.com> wrote:

> 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>

Patch applied to wireless-drivers-next.git, thanks.

afbb1947db94 rtl818x: fix potential use after free
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
index cec3778..1a2ea8b 100644
--- a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
+++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
@@ -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;