Skip to contentSkip to conversation

musb_bulk_rx_nak_timeout()

RFC In review Heinrich Schuchardt 2 participants 2 messages Apr 5, 2021 USB

lore
Share & tools
lore
#0 lore raw

RFC 1/1 musb_bulk_rx_nak_timeout()

Hello Marek,

the code in musb_bulk_rx_nak_timeout() looks fishy:

dma may be set to NULL and dereferenced afterwards.

The following change would avoid the NULL dereference but I am not deep enough into the code to evaluate what is intended here:

(quoted diff) +0 -0

b/drivers/usb/musb-new/musb_host.c
index acb2d40f3b..f495a23d57 100644

drivers/usb/musb-new/musb_host.c +0 -0
@@ -1409,7 +1409,7 @@ static void musb_bulk_rx_nak_timeout(struct musb

*musb, struct musb_hw_ep *ep)

         cur_qh = first_qh(&musb->in_bulk);
         if (cur_qh) {
                 urb = next_urb(cur_qh);
-               if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
+               if (dma && dma_channel_status(dma) ==
MUSB_DMA_STATUS_BUSY) {
                         dma->status = MUSB_DMA_STATUS_CORE_ABORT;
                         musb->dma_controller->channel_abort(dma);
                         urb->actual_length += dma->actual_len;

Best regards

Heinrich

#1 lore raw
Quoted 1 line · Heinrich Schuchardt

Hello Marek,

Hi,

Quoted 21 lines

the code in musb_bulk_rx_nak_timeout() looks fishy:

dma may be set to NULL and dereferenced afterwards.

The following change would avoid the NULL dereference but I am not deep enough into the code to evaluate what is intended here:

drivers/usb/musb-new/musb_host.c +1 -1
index acb2d40f3b..f495a23d57 100644
@@ -1409,7 +1409,7 @@ static void musb_bulk_rx_nak_timeout(struct musb
 *musb, struct musb_hw_ep *ep)
 ?????? cur_qh = first_qh(&musb->in_bulk);
 ?????? if (cur_qh) {
 ?????????????? urb = next_urb(cur_qh);
-?????????????? if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
+?????????????? if (dma && dma_channel_status(dma) ==
 MUSB_DMA_STATUS_BUSY) {
 ?????????????????????? dma->status = MUSB_DMA_STATUS_CORE_ABORT;
Quoted 3 lines

?????????????????????? musb->dma_controller->channel_abort(dma); ?????????????????????? urb->actual_length += dma->actual_len;

I don't have any musb hardware, expanding CC to people who might be able to take a look.