rtlwifi: prevent memory leak in rtl_usb_probe
PATCH 1/1 rtlwifi: prevent memory leak in rtl_usb_probe
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 <[email protected]>
--- drivers/net/wireless/realtek/rtlwifi/usb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/usb.c +4 -1
@@ -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);
Signature · 1 line
2.17.1
Quoted 5 lines · Navid Emamdoost
In
rtl_usb_probeif allocation forusb_datafails the allocated hw should be released. In addition the allocatedrtlpriv->usb_datashould be released on error handling path.Signed-off-by Navid Emamdoost <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
3f9361695113 rtlwifi: prevent memory leak in rtl_usb_probe
Signature · 3 lines
https://patchwork.kernel.org/patch/11159885/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches