fix urb and pipe pointer check order

This commit is contained in:
sakumisu
2022-09-12 20:42:06 +08:00
parent 1df32997ed
commit 2db0dc9a7e
2 changed files with 11 additions and 5 deletions

View File

@@ -754,9 +754,13 @@ int usbh_submit_urb(struct usbh_urb *urb)
size_t flags;
int ret = 0;
if (!urb) {
return -EINVAL;
}
chan = urb->pipe;
if (!urb || !chan) {
if (!chan) {
return -EINVAL;
}
@@ -832,7 +836,7 @@ int usbh_kill_urb(struct usbh_urb *urb)
pipe->urb = NULL;
usb_osal_leave_critical_section(flags);
return 0;
}

View File

@@ -148,8 +148,6 @@ typedef enum {
USB_EP0_STATE_IN_STATUS, /**< IN status*/
USB_EP0_STATE_OUT_DATA, /**< OUT DATA */
USB_EP0_STATE_OUT_STATUS, /**< OUT status */
USB_EP0_STATE_IN_DATA_C, /**< IN status*/
USB_EP0_STATE_IN_STATUS_C, /**< IN DATA */
} ep0_state_t;
struct musb_pipe {
@@ -643,9 +641,13 @@ int usbh_submit_urb(struct usbh_urb *urb)
size_t flags;
int ret = 0;
if (!urb) {
return -EINVAL;
}
pipe = urb->pipe;
if (!urb || !pipe) {
if (!pipe) {
return -EINVAL;
}