* [PATCH] rtlwifi: prevent memory leak in rtl_usb_probe
@ 2019-09-25 1:20 Navid Emamdoost
2019-10-01 9:20 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-09-25 1:20 UTC (permalink / raw)
Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Ping-Ke Shih,
Kalle Valo, David S. Miller, linux-wireless, netdev,
linux-kernel
In rtl_usb_probe if allocation for usb_data fails the allocated hw
should be released. In addition the allocated rtlpriv->usb_data should
be released on error handling path.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/net/wireless/realtek/rtlwifi/usb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index 4b59f3b46b28..348b0072cdd6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1021,8 +1021,10 @@ int rtl_usb_probe(struct usb_interface *intf,
rtlpriv->hw = hw;
rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32),
GFP_KERNEL);
- if (!rtlpriv->usb_data)
+ if (!rtlpriv->usb_data) {
+ ieee80211_free_hw(hw);
return -ENOMEM;
+ }
/* this spin lock must be initialized early */
spin_lock_init(&rtlpriv->locks.usb_lock);
@@ -1083,6 +1085,7 @@ int rtl_usb_probe(struct usb_interface *intf,
_rtl_usb_io_handler_release(hw);
usb_put_dev(udev);
complete(&rtlpriv->firmware_loading_complete);
+ kfree(rtlpriv->usb_data);
return -ENODEV;
}
EXPORT_SYMBOL(rtl_usb_probe);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtlwifi: prevent memory leak in rtl_usb_probe
2019-09-25 1:20 [PATCH] rtlwifi: prevent memory leak in rtl_usb_probe Navid Emamdoost
@ 2019-10-01 9:20 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2019-10-01 9:20 UTC (permalink / raw)
To: Navid Emamdoost
Navid Emamdoost <navid.emamdoost@gmail.com> wrote:
> In rtl_usb_probe if allocation for usb_data fails the allocated hw
> should be released. In addition the allocated rtlpriv->usb_data should
> be released on error handling path.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Patch applied to wireless-drivers-next.git, thanks.
3f9361695113 rtlwifi: prevent memory leak in rtl_usb_probe
--
https://patchwork.kernel.org/patch/11159885/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-01 9:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 1:20 [PATCH] rtlwifi: prevent memory leak in rtl_usb_probe Navid Emamdoost
2019-10-01 9:20 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).