Skip to content

Commit 5afc08c

Browse files
P33Mpopcornmix
authored andcommitted
drivers: usb: dwc_otg: fix reference passing when checking bandwidth
The pointer (struct usb_host_endpoint *)->hcpriv should contain a reference to dwc_otg_qh_t if the driver has already seen a URB submitted to this endpoint. It then checks whether the qh exists and is already in a schedule in order to decide whether to allocate periodic bandwidth or not. Passing a pointer to an offset inside of struct usb_host_endpoint instead of just the pointer means it dereferences bogus addresses. Rationalise (delete) a variable while we're at it. See #5189 Signed-off-by: Jonathan Bell <[email protected]>
1 parent 5c801af commit 5afc08c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,6 @@ static int dwc_otg_urb_enqueue(struct usb_hcd *hcd,
807807
struct usb_host_endpoint *ep = urb->ep;
808808
#endif
809809
dwc_irqflags_t irqflags;
810-
void **ref_ep_hcpriv = &ep->hcpriv;
811810
dwc_otg_hcd_t *dwc_otg_hcd = hcd_to_dwc_otg_hcd(hcd);
812811
dwc_otg_hcd_urb_t *dwc_otg_urb;
813812
int i;
@@ -824,7 +823,7 @@ static int dwc_otg_urb_enqueue(struct usb_hcd *hcd,
824823
if ((usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
825824
|| (usb_pipetype(urb->pipe) == PIPE_INTERRUPT)) {
826825
if (!dwc_otg_hcd_is_bandwidth_allocated
827-
(dwc_otg_hcd, ref_ep_hcpriv)) {
826+
(dwc_otg_hcd, ep->hcpriv)) {
828827
alloc_bandwidth = 1;
829828
}
830829
}
@@ -910,13 +909,12 @@ static int dwc_otg_urb_enqueue(struct usb_hcd *hcd,
910909
#endif
911910
{
912911
retval = dwc_otg_hcd_urb_enqueue(dwc_otg_hcd, dwc_otg_urb,
913-
/*(dwc_otg_qh_t **)*/
914-
ref_ep_hcpriv, 1);
912+
&ep->hcpriv, 1);
915913
if (0 == retval) {
916914
if (alloc_bandwidth) {
917915
allocate_bus_bandwidth(hcd,
918916
dwc_otg_hcd_get_ep_bandwidth(
919-
dwc_otg_hcd, *ref_ep_hcpriv),
917+
dwc_otg_hcd, ep->hcpriv),
920918
urb);
921919
}
922920
} else {

0 commit comments

Comments
 (0)