Skip to content

Commit 3f93616

Browse files
NavidemKalle Valo
authored and
Kalle Valo
committed
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 <navid.emamdoost@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent 6e7d597 commit 3f93616

File tree

1 file changed

+4
-1
lines changed
  • drivers/net/wireless/realtek/rtlwifi

1 file changed

+4
-1
lines changed

Diff for: drivers/net/wireless/realtek/rtlwifi/usb.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,10 @@ int rtl_usb_probe(struct usb_interface *intf,
10211021
rtlpriv->hw = hw;
10221022
rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32),
10231023
GFP_KERNEL);
1024-
if (!rtlpriv->usb_data)
1024+
if (!rtlpriv->usb_data) {
1025+
ieee80211_free_hw(hw);
10251026
return -ENOMEM;
1027+
}
10261028

10271029
/* this spin lock must be initialized early */
10281030
spin_lock_init(&rtlpriv->locks.usb_lock);
@@ -1083,6 +1085,7 @@ int rtl_usb_probe(struct usb_interface *intf,
10831085
_rtl_usb_io_handler_release(hw);
10841086
usb_put_dev(udev);
10851087
complete(&rtlpriv->firmware_loading_complete);
1088+
kfree(rtlpriv->usb_data);
10861089
return -ENODEV;
10871090
}
10881091
EXPORT_SYMBOL(rtl_usb_probe);

0 commit comments

Comments
 (0)