summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-09-12 20:42:06 +0800
committersakumisu <[email protected]>2022-09-12 20:42:06 +0800
commit2db0dc9a7e0aa9bdd46426906d974d6e94d6d1c1 (patch)
treed6dfc261ab174a32ad510781d1a817932e68cdef
parent1df32997eddb5b50c5a804cf7bfbd63866a402e2 (diff)
fix urb and pipe pointer check order
-rw-r--r--port/dwc2/usb_hc_dwc2.c8
-rw-r--r--port/musb/usb_hc_musb.c8
2 files changed, 11 insertions, 5 deletions
diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c
index cc29203f..24d9da21 100644
--- a/port/dwc2/usb_hc_dwc2.c
+++ b/port/dwc2/usb_hc_dwc2.c
@@ -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;
}
diff --git a/port/musb/usb_hc_musb.c b/port/musb/usb_hc_musb.c
index 9c4d0d3f..32afeb3b 100644
--- a/port/musb/usb_hc_musb.c
+++ b/port/musb/usb_hc_musb.c
@@ -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;
}