1
0
Fork 0
alistair23-linux/drivers/usb/c67x00
Tom Rix 4f0addeba0 USB: c67x00: fix use after free in c67x00_giveback_urb
commit 211f083473 upstream.

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-22 09:33:09 +02:00
..
Makefile USB: add SPDX identifiers to all remaining Makefiles 2017-11-07 15:53:48 +01:00
c67x00-drv.c USB: c67x00: Remove redundant license text 2017-11-07 15:45:02 +01:00
c67x00-hcd.c USB: c67x00: Remove redundant license text 2017-11-07 15:45:02 +01:00
c67x00-hcd.h USB: c67x00: Remove redundant license text 2017-11-07 15:45:02 +01:00
c67x00-ll-hpi.c USB: c67x00: Remove redundant license text 2017-11-07 15:45:02 +01:00
c67x00-sched.c USB: c67x00: fix use after free in c67x00_giveback_urb 2020-07-22 09:33:09 +02:00
c67x00.h USB: c67x00: Remove redundant license text 2017-11-07 15:45:02 +01:00