usb_kill_urb(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… usb_kill_urb β€” kernel API manual, bestie edition

okay so you know usb_kill_urb(9)? that's the one. this is the kernel API manual page for it, and we're gonna get through it together, no cap 🫢


✨ NAME ✨

usb_kill_urb β€” cancel a transfer request and wait for it to finish πŸ’€β³

yeah. it cancels. and it waits. both. it does the most, honestly.


🌸 SYNOPSIS 🌸

void usb_kill_urb (struct urb *urb );

that's it. that's the whole signature. void, so nothing comes back to you β€” she's not returning anything, she's just done when she's done. πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • urb β€” pointer to a URB describing a previously submitted request, and yes it may be NULL. your girl is allowed to be a NULL pointer, she contains multitudes πŸ™ˆ

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea β˜• β€” this routine cancels an in-progress request. and it is guaranteed that upon return, all completion handlers will have finished and the URB will be totally idle and available for reuse. like, fully rested, skin clear, ready to go again ✨

these features make this an ideal way to stop I/O in a disconnect callback or close function. it's literally giving "responsible friend who makes sure everyone gets home safe" energy 🫢

if the request has not already finished or been unlinked, the completion handler will see urb->status == -ENOENT. so heads up, your handler's gonna get that value and be like "oh 😭" β€” that's expected, that's correct.

while the routine is running, attempts to resubmit the URB will fail with error -EPERM. so even if the URB's completion handler always tries to resubmit (we all know that one handler), it will not succeed and the URB will become idle. the routine said "sit down." and it sat down πŸ’…

🚨 big one, bestie, do not skip: 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, that's a real rule, not a vibe, fr fr 😭
⚠️ 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. if you can't schedule, you can't be here. that's the whole thing. periodt.
πŸ’€ and this routine should not be called by a driver after its disconnect method has returned. after that, it's over, it's giving "the party ended an hour ago," go home πŸŒ™

πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./drivers/usb/core/urb.c β€” that's the main character source file, go read it 🧚

and the whole friend group:

they're all icons, they all ate πŸ”₯


πŸŽ€ sign-off πŸŽ€

this masterpiece lives in ./drivers/usb/core, dated October 2026, and it's part of the Kernel API Manual. ngl, a whole manual page about waiting for your URB to finish? highkey iconic. go forth and kill your URBs responsibly, bestie πŸ’œπŸŒˆβ­

πŸ“¦ where this page comes from