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

staging: rtl8192u: Fix some error handling path

If 'rtl8192_usb_initendpoints()' fails, it may have allocated some
resources that need to be freed. The corresponding is propagated up to
'rtl8192_usb_prob()'. So, in this function if an error
code is returned by 'rtl8192_init()' we should call
'rtl8192_usb_deleteendpoints()'.

Some error handling code is also duplicated in 'rtl8192_init()' and in
'rtl8192_usb_prob()'. This looks harmless because the freed pointers are
set to NULL but it looks confusing.

Fix all that by just moving the 'fail' label and removing duplicated
error handling code from 'rtl8192_ini()'. All this resources freeing will
be handled by 'rtl8192_usb_prob()' directly.

The calling graph is:
rtl8192_usb_probe
--> rtl8192_init
--> rtl8192_usb_initendpoints

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
6e6c6dee 5fef87cb

+1 -4
+1 -4
drivers/staging/rtl8192u/r8192U_core.c
··· 2694 2694 err = rtl8192_read_eeprom_info(dev); 2695 2695 if (err) { 2696 2696 DMESG("Reading EEPROM info failed"); 2697 - kfree(priv->pFirmware); 2698 - priv->pFirmware = NULL; 2699 - free_ieee80211(dev); 2700 2697 return err; 2701 2698 } 2702 2699 rtl8192_get_channel_map(dev); ··· 4995 4998 4996 4999 fail2: 4997 5000 rtl8192_down(dev); 5001 + fail: 4998 5002 kfree(priv->pFirmware); 4999 5003 priv->pFirmware = NULL; 5000 5004 rtl8192_usb_deleteendpoints(dev); 5001 5005 mdelay(10); 5002 - fail: 5003 5006 free_ieee80211(dev); 5004 5007 5005 5008 RT_TRACE(COMP_ERR, "wlan driver load failed\n");