summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJerzy Kasenberg <[email protected]>2020-04-27 16:42:35 +0200
committerJerzy Kasenberg <[email protected]>2020-04-27 16:42:35 +0200
commit63cefb761535bf9f9f86a261c4a7ba07710c6c1d (patch)
treed1c6ab1c91bbdce06ea9b1e3447f80bf9966b765 /src
parentd54343e4a6bc84549caf69ecd26a98852127ef3f (diff)
Fix endpoint busy flag race condition
Busy flag was set to true after call to dcd_edpt_xfer(). In some cased it was possible that transfer finished before function ended. In this case busy flag could be set to false before it was set to true. Then setting it to true after dcd_edpt_xfer() made edpoint busy forever. This change marks endpoint as busy before transfer is started to avoid race condition.
Diffstat (limited to 'src')
-rw-r--r--src/device/usbd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index f0b7fcefc..2042d35b7 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -982,8 +982,8 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
TU_LOG2(" Queue EP %02X with %u bytes ... ", ep_addr, total_bytes);
- TU_VERIFY( dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes) );
_usbd_dev.ep_status[epnum][dir].busy = true;
+ TU_VERIFY_HDLR( dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes), _usbd_dev.ep_status[epnum][dir].busy = false);
TU_LOG2("OK\r\n");