kernel_optimize_test/drivers/usb/gadget
Alan Stern 656eca37aa USB: gadget: Fix double-free bug in raw_gadget driver
commit 90bc2af24638659da56397ff835f3c95a948f991 upstream.

Re-reading a recently merged fix to the raw_gadget driver showed that
it inadvertently introduced a double-free bug in a failure pathway.
If raw_ioctl_init() encounters an error after the driver ID number has
been allocated, it deallocates the ID number before returning.  But
when dev_free() runs later on, it will then try to deallocate the ID
number a second time.

Closely related to this issue is another error in the recent fix: The
ID number is stored in the raw_dev structure before the code checks to
see whether the structure has already been initialized, in which case
the new ID number would overwrite the earlier value.

The solution to both bugs is to keep the new ID number in a local
variable, and store it in the raw_dev structure only after the check
for prior initialization.  No errors can occur after that point, so
the double-free will never happen.

Fixes: f2d8c2606825 ("usb: gadget: Fix non-unique driver names in raw-gadget driver")
CC: Andrey Konovalov <andreyknvl@gmail.com>
CC: <stable@vger.kernel.org>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/YrMrRw5AyIZghN0v@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-29 08:59:51 +02:00
..
function usb: gadget: u_ether: fix regression in setting fixed MAC address 2022-06-25 15:16:08 +02:00
legacy USB: gadget: Fix double-free bug in raw_gadget driver 2022-06-29 08:59:51 +02:00
udc usb: gadget: lpc32xx_udc: Fix refcount leak in lpc32xx_udc_probe 2022-06-22 14:13:19 +02:00
composite.c USB: gadget: validate interface OS descriptor requests 2022-02-16 12:54:28 +01:00
config.c usb: fix various gadget panics on 10gbps cabling 2021-06-16 12:01:43 +02:00
configfs.c usb: gadget: configfs: clear deactivation flag in configfs_composite_unbind() 2022-05-09 09:04:58 +02:00
configfs.h
epautoconf.c
functions.c
Kconfig
Makefile
u_f.c
u_f.h
u_os_desc.h
usbstring.c