Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

usbh: tuh_edpt_abort_xfer releases the endpoint even when the HCD had nothing to abort

Open
#4,178 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

Read src/host/usbh.c around tuh_edpt_abort_xfer() and the abort-return contract in hcd.h first. Audit the HCD implementations named in the issue: rusb2, musb, ohci, ch32_usbfs, template, max3421, and ip3516. Done means their return values consistently indicate whether an abort occurred and usbh preserves the queued-completion behavior when nothing was aborted.

Written by the indexing model from the issue text.

Description

followup Prio 📌

From #4177. tuh_edpt_abort_xfer() clears BUSY and releases a non-control endpoint whatever hcd_edpt_abort_xfer() returns: https://github.com/hathach/tinyusb/blob/7936dae4e/src/host/usbh.c#L1260-L1262

If the transfer completed just before the abort, its completion event is already queued. The abort finds nothing to cancel, usbh releases the endpoint, the caller re-arms it, and then the queued event runs: it clears the new transfer's BUSY/CLAIMED and invokes the callback, so the class arms the endpoint a second time.

Evidence: hit on raspberry_pi_pico2 with a stress hook that aborted and re-armed the hub status endpoint every frame: rp2040 int_edpt_abort reported "already completed" once, then the second arm panicked buf_ctrl @ 0x50100088 already available. With the hook changed to re-arm only when the HCD abort returned true, 3×7084 cycles ran clean.

Remaining work

  • usbh should leave BUSY set (the queued completion releases it) when hcd_edpt_abort_xfer() returns false, as hcd.h documents.
  • HCD returns are inconsistent today (rusb2, musb, ohci, ch32_usbfs, template return false unconditionally or for unsupported cases; max3421, ip3516 return true), so each port needs auditing before usbh relies on the return.

Why deferred: cross-HCD change; #4177 only makes rp2040 return false when nothing was active.

Dominant language
C
Stars
7.2k
Forks
1.6k
Avg merge
2d 4h
Merged PRs (30d)
100

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hathach/tinyusb

All issues in hathach/tinyusb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.