mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
rtlwifi: prevent memory leak in rtl_usb_probe
[ Upstream commit 3f93616951 ]
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>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
@@ -1088,8 +1088,10 @@ int rtl_usb_probe(struct usb_interface *intf,
|
||||
rtlpriv->hw = hw;
|
||||
rtlpriv->usb_data = kzalloc(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);
|
||||
@@ -1152,6 +1154,7 @@ error_out:
|
||||
_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);
|
||||
|
||||
Reference in New Issue
Block a user