Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexey Khoroshilov and committed by
Greg Kroah-Hartman
b76ed59f 509e42e1

+6 -4
+6 -4
drivers/staging/wlan-ng/prism2usb.c
··· 140 140 prism2_reset_holdtime, 141 141 prism2_reset_settletime, 0); 142 142 if (result != 0) { 143 - unregister_wlandev(wlandev); 144 - hfa384x_destroy(hw); 145 143 result = -EIO; 146 144 dev_err(&interface->dev, "hfa384x_corereset() failed.\n"); 147 - goto failed; 145 + goto failed_reset; 148 146 } 149 147 } 150 148 ··· 157 159 if (register_wlandev(wlandev) != 0) { 158 160 dev_err(&interface->dev, "register_wlandev() failed.\n"); 159 161 result = -EIO; 160 - goto failed; 162 + goto failed_register; 161 163 } 162 164 163 165 goto done; 164 166 167 + failed_register: 168 + usb_put_dev(dev); 169 + failed_reset: 170 + wlan_unsetup(wlandev); 165 171 failed: 166 172 kfree(wlandev); 167 173 kfree(hw);