Potential issue in xhci-ring handle_tx_event()
Quoted 7 lines · Dan Carpenter
Btw,
xhci-ring.ccauses some valid looking gcc warnings:C [M]
drivers/usb/host/xhci-ring.odrivers/usb/host/xhci-ring.c: In function ‘handle_port_status’:drivers/usb/host/xhci-ring.c:1229: warning: ‘hcd’ may be used uninitialized in this functiondrivers/usb/host/xhci-ring.c: In function ‘handle_tx_event’:drivers/usb/host/xhci-ring.c:1895: warning: ‘event_trb’ may be used uninitialized in this function
Oh, actually, looking through my mail, Dmitry also noticed the event_trb issue last week and started on a patch to fix it (see below).
Dmitry, can you please send a proper patch?
Thanks,
Sarah Sharp
Quoted 60 lines · Dmitry Torokhov
Hi Andiry, Sarah,
I was compiling xhci and got a warning that
event_trbmight be used uninitialized inhandle_tx_event(). Looking at the implementation the logic is quite convoluted but appears that if the following condition is true:!event_seg && ep->skip && usb_endpoint_xfer_isoc(...)we indeed will end up calling process_*_td(...,
event_trb, ...).I think something like the following is needed...
drivers/usb/host/xhci-ring.c +14
-10@@ -1918,22 +1918,26 @@ static int handle_tx_event(struct xhci_hcd *xhci, } td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list); +/* Is this a TRB in the currently executing TD? */ event_seg =trb_in_td (ep_ring->deq_seg, ep_ring->dequeue, td->last_trb, event_dma); -if (event_seg && ep->skip) { -xhci_dbg (xhci,"Found td. Clear skip flag.\n" ); - ep->skip = false; - } -if (!event_seg && - (!ep->skip || !usb_endpoint_xfer_isoc (&td->urb->ep->desc))) { +if (!event_seg) { +if (ep->skip && +usb_endpoint_xfer_isoc (&td->urb->ep->desc)) { + ret =0 ; + goto cleanup; + }/* HC is busted, give up! */ -xhci_err (xhci,"ERROR Transfer event TRB DMA ptr not " -"part of current TD\n" ); +xhci_err (xhci, +"ERROR Transfer event TRB DMA ptr not part of current TD\n" );return -ESHUTDOWN ; - } + }else { +if (ep->skip) { +xhci_dbg (xhci,"Found td. Clear skip flag.\n" ); + ep->skip = false; + } -if (event_seg) { event_trb = &event_seg->trbs[(event_dma - event_seg->dma) /sizeof (*event_trb)];/* Thanks.
Signature · 1 line
Dmitry