diff options
| author | aineoae86-sys <[email protected]> | 2026-07-05 16:19:03 +0800 |
|---|---|---|
| committer | aineoae86-sys <[email protected]> | 2026-07-05 18:24:04 +0800 |
| commit | 742ca33c8a727e9aa92f8a78526b53a8dd45a304 (patch) | |
| tree | eb558842c024c8b73718c10cf434ba2f719e6152 | |
| parent | 41b8ad203990da258e98531c6bf77102c7cc7c68 (diff) | |
Fix USBTMC notification endpoint claim
Use usbd_edpt_claim() before queuing USBTMC notification data so the interrupt endpoint is reserved through the normal endpoint ownership path. Release the claim if the notification payload cannot be copied before the transfer is queued.
Fixes #2735
Generated-by: OpenAI Codex
Signed-off-by: aineoae86-sys <[email protected]>
| -rw-r--r-- | src/class/usbtmc/usbtmc_device.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/class/usbtmc/usbtmc_device.c b/src/class/usbtmc/usbtmc_device.c index ae1d5fa9a..eebc34cfe 100644 --- a/src/class/usbtmc/usbtmc_device.c +++ b/src/class/usbtmc/usbtmc_device.c @@ -252,9 +252,12 @@ bool tud_usbtmc_transmit_notification_data(const void *data, size_t len) { TU_ASSERT(len > 0); TU_ASSERT(usbtmc_state.ep_int_in != 0); #endif - TU_VERIFY(usbd_edpt_busy(usbtmc_state.rhport, usbtmc_state.ep_int_in)); + TU_VERIFY(usbd_edpt_claim(usbtmc_state.rhport, usbtmc_state.ep_int_in)); - TU_VERIFY(tu_memcpy_s(usbtmc_epbuf.epnotif, CFG_TUD_USBTMC_INT_EP_SIZE, data, len) == 0); + if (tu_memcpy_s(usbtmc_epbuf.epnotif, CFG_TUD_USBTMC_INT_EP_SIZE, data, len) != 0) { + usbd_edpt_release(usbtmc_state.rhport, usbtmc_state.ep_int_in); + return false; + } TU_VERIFY(usbd_edpt_xfer(usbtmc_state.rhport, usbtmc_state.ep_int_in, usbtmc_epbuf.epnotif, (uint16_t) len, false)); return true; } |
