Commit b76ed59f authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Greg Kroah-Hartman

staging: wlan-ng: fix leaks on failure paths in prism2sta_probe_usb()

There are leaks of resources allocated by wlan_setup() and usb_dev refcnt
on failure paths in prism2sta_probe_usb().

The patch adds appropriate deallocations and removes invalid code
from hfa384x_corereset() failure handling.
unregister_wlandev() is wrong because it is not registered yet.
hfa384x_destroy() is just noop in init state.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 509e42e1
...@@ -140,11 +140,9 @@ static int prism2sta_probe_usb(struct usb_interface *interface, ...@@ -140,11 +140,9 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
prism2_reset_holdtime, prism2_reset_holdtime,
prism2_reset_settletime, 0); prism2_reset_settletime, 0);
if (result != 0) { if (result != 0) {
unregister_wlandev(wlandev);
hfa384x_destroy(hw);
result = -EIO; result = -EIO;
dev_err(&interface->dev, "hfa384x_corereset() failed.\n"); dev_err(&interface->dev, "hfa384x_corereset() failed.\n");
goto failed; goto failed_reset;
} }
} }
...@@ -159,11 +157,15 @@ static int prism2sta_probe_usb(struct usb_interface *interface, ...@@ -159,11 +157,15 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
if (register_wlandev(wlandev) != 0) { if (register_wlandev(wlandev) != 0) {
dev_err(&interface->dev, "register_wlandev() failed.\n"); dev_err(&interface->dev, "register_wlandev() failed.\n");
result = -EIO; result = -EIO;
goto failed; goto failed_register;
} }
goto done; goto done;
failed_register:
usb_put_dev(dev);
failed_reset:
wlan_unsetup(wlandev);
failed: failed:
kfree(wlandev); kfree(wlandev);
kfree(hw); kfree(hw);
......
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