linux/drivers/usb
Uttkarsh Aggarwal c7ebd8149e usb: dwc3: gadget: Fix NULL pointer dereference in dwc3_gadget_suspend
commit 61a348857e upstream.

In current scenario if Plug-out and Plug-In performed continuously
there could be a chance while checking for dwc->gadget_driver in
dwc3_gadget_suspend, a NULL pointer dereference may occur.

Call Stack:

	CPU1:                           CPU2:
	gadget_unbind_driver            dwc3_suspend_common
	dwc3_gadget_stop                dwc3_gadget_suspend
                                        dwc3_disconnect_gadget

CPU1 basically clears the variable and CPU2 checks the variable.
Consider CPU1 is running and right before gadget_driver is cleared
and in parallel CPU2 executes dwc3_gadget_suspend where it finds
dwc->gadget_driver which is not NULL and resumes execution and then
CPU1 completes execution. CPU2 executes dwc3_disconnect_gadget where
it checks dwc->gadget_driver is already NULL because of which the
NULL pointer deference occur.

Cc: stable@vger.kernel.org
Fixes: 9772b47a4c ("usb: dwc3: gadget: Fix suspend/resume during device mode")
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Uttkarsh Aggarwal <quic_uaggarwa@quicinc.com>
Link: https://lore.kernel.org/r/20240119094825.26530-1-quic_uaggarwa@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 09:24:57 +01:00
..
atm
c67x00
cdns3 usb: cdns3: Fix uvc fail when DMA cross 4k boundery since sg enabled 2024-01-25 15:35:43 -08:00
chipidea usb: chipidea: core: handle power lost in workqueue 2024-02-23 09:24:57 +01:00
class usb: cdc-acm: return correct error code on unsupported break 2024-01-25 15:35:53 -08:00
common usb: ulpi: Fix debugfs directory leak 2024-02-23 09:24:56 +01:00
core usb: core: Prevent null pointer dereference in update_port_device_state 2024-02-23 09:24:57 +01:00
dwc2 USB: dwc2: write HCINT with INTMASK applied 2023-12-03 07:33:10 +01:00
dwc3 usb: dwc3: gadget: Fix NULL pointer dereference in dwc3_gadget_suspend 2024-02-23 09:24:57 +01:00
early
fotg210 usb: fotg210-hcd: delete an incorrect bounds test 2024-01-01 12:42:41 +00:00
gadget usb: f_mass_storage: forbid async queue when shutdown happen 2024-02-23 09:24:56 +01:00
host xhci: handle isoc Babble and Buffer Overrun events properly 2024-02-16 19:10:55 +01:00
image
isp1760
misc usb: misc: onboard-hub: add support for Microchip USB5744 2023-12-03 07:33:08 +01:00
mon usb: mon: Fix atomicity violation in mon_bin_vma_fault 2024-01-25 15:35:43 -08:00
mtu3
musb
phy usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host() 2024-01-25 15:35:42 -08:00
renesas_usbhs
roles
serial USB: serial: cp210x: add ID for IMST iM871A-USB 2024-02-16 19:10:54 +01:00
storage usb-storage: Add quirk for incorrect WP on Kingston DT Ultimate 3.0 G3 2024-01-01 12:42:38 +00:00
typec usb: ucsi_acpi: Fix command completion handling 2024-02-23 09:24:56 +01:00
usbip
Kconfig
Makefile
usb-skeleton.c