usb_poison_urb(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… usb_poison_urb(9) β€” the Kernel API Manual, but make it make sense πŸŽ€

okay so bestie, welcome to usb_poison_urb(9), the one where we reliably kill a transfer and prevent further use of an URB. yes. that's the whole vibe. it's giving "we're done here" energy and honestly? iconic. ✨


✨ SYNOPSIS ✨

void usb_poison_urb (struct urb *urb);

that's it. that's the whole call. one (1) pointer, no return value, maximum chaos potential. πŸ¦‹


🌸 ARGUMENTS 🌸

  • urb β€” pointer to the URB describing a request you already submitted, and guess what: it may be NULL. fr fr, that's allowed. 🫢

πŸ’œ DESCRIPTION πŸ’œ

So what does this thing actually do? It cancels an in-progress request, and it does it hard. Like, guaranteed hard. πŸ’€

When this routine returns, you have my word: all completion handlers will have finished, and the URB will be totally idle and cannot be reused. Not "shouldn't", not "probably won't" β€” cannot. That's the whole point, and it's exactly why this is the ideal way to stop I/O in a disconnect callback. πŸ‘‘

And here's the tea πŸ“: if the request hasn't already finished or been unlinked, the completion handler is gonna see this:

urb->status == -ENOENT

yes bestie, -ENOENT. that's the signal. 😭

Now, after this routine runs β€” and honestly while it's running too β€” any attempt to resubmit the URB will fail with error -EPERM. so even if the URB's completion handler is that one friend who always tries to resubmit… it will not succeed, and the URB will become idle. no cap. the door is locked. πŸšͺπŸ”’

⚠️ BIG IMPORTANT ONE, do not skip this: The URB must not be deallocated while this routine is running. In particular, when a driver calls this routine, it must insure that the completion handler cannot deallocate the URB. like, you literally cannot let that happen. it's not a vibe. it's a crash. πŸ’€
⚠️ Also: This routine may not be used in an interrupt context (such as a bottom half or a completion handler), or when holding a spinlock, or in other situations where the caller can't schedule. so if you can't schedule, you can't call this. periodt. βœ‹
⚠️ And one more: This routine should not be called by a driver after its disconnect method has returned. like, that window's closed, bestie. the store is shut. πŸ™ˆ

🌈 SEE ALSO 🌈

Kernel file ./drivers/usb/core/urb.c β€” go read it, it's the source of truth πŸ’– β€” plus this whole friend group right here:


and that's the page! πŸ§šβ€β™€οΈ

cute lil sign-off moment: this one lives in ./drivers/usb/core, dated October 2026, and the whole thing is usb_poison_urb(9) β€” you're welcome, go poison some URBs responsibly πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from