alloc_ep_req(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… alloc_ep_req β€” Kernel API Manual, section 9 πŸŽ€

okay bestie, welcome to alloc_ep_req(9), straight out of the Kernel API Manual (section 9, we love a numbered era). this one's a lil USB gadget helper and it's honestly so much chiller than it sounds, i promise 🫢


✨ NAME ✨

alloc_ep_req β€” returns a usb_request allocated by the gadget driver, and allocates the request's buffer. that's it, that's the whole gig πŸ’–


🌸 SYNOPSIS 🌸

struct usb_request * alloc_ep_req (struct usb_ep *ep , size_t len );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • ep β€” the endpoint you're allocating a usb_request for, bestie. point it at the right one πŸ‘‘
  • len β€” the suggested size for the usb_request's buffer. suggested, okay, remember that word, it's gonna matter in a sec πŸ‘€

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea πŸ“: if ep's direction is OUT, the len you pass in gets aligned to ep's wMaxPacketSize. like, it's not gonna be exactly what you asked for, so don't come for her when the number's different.

and this is the part where i hold your hand: to avoid memory leaks or drops, always use the usb_request's length β€” that's req->length β€” to refer to the allocated buffer size. always always always. not your original len, not vibes, not what you remember passing in. req->length. periodt πŸ’…

also, requests allocated via alloc_ep_req must be freed by free_ep_req. this is not a suggestion, this is the law. no main character energy where you free it some other way, you will leak and it will be tragic 😭

🌈 SEE ALSO 🌈

  • Kernel file ./include/linux/usb/func_utils.h β€” go read it, iykyk 🧚

and that's the page!! sending u off with the cutest sign-off i got: this lil doc lives in ./include/linux/usb, dated October 2026, so it's basically from the future and still slaying βœ¨πŸ’…πŸ”₯

πŸ“¦ where this page comes from