Commit 86279456 authored by Chris Chiu's avatar Chris Chiu Committed by Kalle Valo

rtl8xxxu: prevent potential memory leak

Free the skb if usb_submit_urb fails on rx_urb. And free the urb
no matter usb_submit_urb succeeds or not in rtl8xxxu_submit_int_urb.
Signed-off-by: default avatarChris Chiu <chiu@endlessm.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200906040424.22022-1-chiu@endlessm.com
parent 587231ee
...@@ -5795,7 +5795,6 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw) ...@@ -5795,7 +5795,6 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw)
ret = usb_submit_urb(urb, GFP_KERNEL); ret = usb_submit_urb(urb, GFP_KERNEL);
if (ret) { if (ret) {
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
usb_free_urb(urb);
goto error; goto error;
} }
...@@ -5804,6 +5803,7 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw) ...@@ -5804,6 +5803,7 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw)
rtl8xxxu_write32(priv, REG_USB_HIMR, val32); rtl8xxxu_write32(priv, REG_USB_HIMR, val32);
error: error:
usb_free_urb(urb);
return ret; return ret;
} }
...@@ -6318,6 +6318,7 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw) ...@@ -6318,6 +6318,7 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw)
struct rtl8xxxu_priv *priv = hw->priv; struct rtl8xxxu_priv *priv = hw->priv;
struct rtl8xxxu_rx_urb *rx_urb; struct rtl8xxxu_rx_urb *rx_urb;
struct rtl8xxxu_tx_urb *tx_urb; struct rtl8xxxu_tx_urb *tx_urb;
struct sk_buff *skb;
unsigned long flags; unsigned long flags;
int ret, i; int ret, i;
...@@ -6368,6 +6369,13 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw) ...@@ -6368,6 +6369,13 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw)
rx_urb->hw = hw; rx_urb->hw = hw;
ret = rtl8xxxu_submit_rx_urb(priv, rx_urb); ret = rtl8xxxu_submit_rx_urb(priv, rx_urb);
if (ret) {
if (ret != -ENOMEM) {
skb = (struct sk_buff *)rx_urb->urb.context;
dev_kfree_skb(skb);
}
rtl8xxxu_queue_rx_urb(priv, rx_urb);
}
} }
schedule_delayed_work(&priv->ra_watchdog, 2 * HZ); schedule_delayed_work(&priv->ra_watchdog, 2 * HZ);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment