linux-stable/drivers/usb
Tom Rix 211f083473 USB: c67x00: fix use after free in c67x00_giveback_urb
clang static analysis flags this error

c67x00-sched.c:489:55: warning: Use of memory after it is freed [unix.Malloc]
        usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, urbp->status);
                                                             ^~~~~~~~~~~~
Problem happens in this block of code

	c67x00_release_urb(c67x00, urb);
	usb_hcd_unlink_urb_from_ep(c67x00_hcd_to_hcd(c67x00), urb);
	spin_unlock(&c67x00->lock);
	usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, urbp->status);

In the call to c67x00_release_urb has this freeing of urbp

	urbp = urb->hcpriv;
	urb->hcpriv = NULL;
	list_del(&urbp->hep_node);
	kfree(urbp);

And so urbp is freed before usb_hcd_giveback_urb uses it as its 3rd
parameter.

Since all is required is the status, pass the status directly as is
done in c64x00_urb_dequeue

Fixes: e9b29ffc51 ("USB: add Cypress c67x00 OTG controller HCD driver")
Signed-off-by: Tom Rix <trix@redhat.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200708131243.24336-1-trix@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-10 09:01:41 +02:00
..
atm USB: atm: Use the correct style for SPDX License Identifier 2020-03-17 20:03:28 +01:00
c67x00 USB: c67x00: fix use after free in c67x00_giveback_urb 2020-07-10 09:01:41 +02:00
cdns3 usb: cdns3: ep0: add spinlock for cdns3_check_new_setup 2020-06-24 16:02:58 +02:00
chipidea usb: chipidea: core: add wakeup support for extcon 2020-07-07 19:57:21 +02:00
class cdc-acm: Add DISABLE_ECHO quirk for Microchip/SMSC chip 2020-06-18 10:42:52 +02:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-10 11:41:20 +01:00
core usb: add USB_QUIRK_DELAY_INIT for Logitech C922 2020-06-18 10:42:18 +02:00
dwc2 usb: dwc2: Postponed gadget registration to the udc class driver 2020-06-18 10:42:52 +02:00
dwc3 Revert "usb: dwc3: exynos: Add support for Exynos5422 suspend clk" 2020-06-24 16:05:00 +02:00
early kdb: Switch to use safer dbg_io_ops over console APIs 2020-06-26 15:40:16 +01:00
gadget usb: gadget: udc: Potential Oops in error handling code 2020-06-24 09:45:58 +03:00
host xhci: Poll for U0 after disabling USB2 LPM 2020-06-24 16:03:41 +02:00
image treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
isp1760 USB: isp1760: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
misc usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect 2020-06-18 10:42:52 +02:00
mon USB: mon: Use scnprintf() for avoiding potential buffer overflow 2020-03-12 09:49:28 +01:00
mtu3 USB: mtu3: Use the correct style for SPDX License Identifier 2020-05-25 11:09:37 +03:00
musb usb: musb: Fix runtime PM imbalance on error 2020-05-25 13:36:31 +02:00
phy usb: phy: tegra: Fix unnecessary check in tegra_usb_phy_probe() 2020-06-24 09:43:16 +03:00
renesas_usbhs usb: renesas_usbhs: getting residue from callback_result 2020-06-24 17:14:44 +02:00
roles usb: roles: Switch on role-switch uevent reporting 2020-05-13 14:20:49 +02:00
serial USB: serial: option: add Quectel EG95 LTE modem 2020-07-07 17:40:52 +02:00
storage treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
typec usb: typec: tcpci_rt1711h: avoid screaming irq causing boot hangs 2020-06-18 10:42:53 +02:00
usbip treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile
usb-skeleton.c