From c2876eb8c87ba3730de90a375348017f4602ccc6 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sun, 21 Jul 2019 14:12:30 +0200
Subject: [PATCH] fix(maxusb): Always exit critical sections

---
 lib/sdk/Libraries/MAXUSB/src/core/musbhsfc/usb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/sdk/Libraries/MAXUSB/src/core/musbhsfc/usb.c b/lib/sdk/Libraries/MAXUSB/src/core/musbhsfc/usb.c
index 3c2897f5..ffd12a76 100644
--- a/lib/sdk/Libraries/MAXUSB/src/core/musbhsfc/usb.c
+++ b/lib/sdk/Libraries/MAXUSB/src/core/musbhsfc/usb.c
@@ -879,6 +879,8 @@ int usb_get_setup(usb_setup_pkt *sud)
     MXC_USBHS->index = 0;
 
     if ((sud == NULL) || !(MXC_USBHS->csr0 & MXC_F_USBHS_CSR0_OUTPKTRDY)) {
+        printf("MAXUSB ISSUE 3\n");
+        MAXUSB_EXIT_CRITICAL();
         return -1;
     }
 
@@ -1027,6 +1029,8 @@ int usb_read_endpoint(usb_req_t *req)
 
     /* EP must be enabled (configured) and not stalled */
     if (!usb_is_configured(ep)) {
+        printf("MAXUSB ISSUE 1\n");
+        MAXUSB_EXIT_CRITICAL();
         return -1;
     }
 
@@ -1099,6 +1103,9 @@ int usb_read_endpoint(usb_req_t *req)
                 MAXUSB_EXIT_CRITICAL();
             }
         }
+    } else {
+        printf("MAXUSB ISSUE 2\n");
+        MAXUSB_EXIT_CRITICAL();
     }
 
     return 0;
-- 
GitLab