RE: [PATCH] usb: renesas_usbhs: fix error return code of usbhsf_pkt_handler()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jia-Ju,

Thank you for the patch!

> From: Jia-Ju Bai, Sent: Sunday, March 7, 2021 6:01 PM
> 
> When __usbhsf_pkt_get() returns NULL to pkt, no error return code of
> usbhsf_pkt_handler() is assigned.

Yes. Also I realized that no error return code of usbhsf_pkt_handler()
was assigned if the type value was unexpected value. So, I'm thinking
initial value of ret should be -EINVAL instead of 0.
---
        int ret = 0;  // should be -EINVAL
        int is_done = 0;

        /********************  spin lock ********************/
        usbhs_lock(priv, flags);

        pkt = __usbhsf_pkt_get(pipe);
        if (!pkt)
                goto __usbhs_pkt_handler_end;

        switch (type) {
        case USBHSF_PKT_PREPARE:
                func = pkt->handler->prepare;
                break;
        case USBHSF_PKT_TRY_RUN:
                func = pkt->handler->try_run;
                break;
        case USBHSF_PKT_DMA_DONE:
                func = pkt->handler->dma_done;
                break;
        default:
                dev_err(dev, "unknown pkt handler\n");
                goto __usbhs_pkt_handler_end;    /// here
        }

        if (likely(func))  /// [1]
                ret = func(pkt, &is_done);

[1] This is always true here, so ret is always assigned by the func().
---

> To fix this bug, ret is assigned with -EINVAL in this case.

Just a record: After fixed this, actual behavior is almost the same
except printing error message.

Best regards,
Yoshihiro Shimoda





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux