__kmemdup_nul(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– __kmemdup_nul β€” Kernel API Manual, but make it make sense πŸ’–

okay so bestie, welcome to the <pink>Kernel API Manual</pink> entry for __kmemdup_nul(9) β€” yes the double-underscore one, she's the ✨internal✨ girlie, put some respect on her name πŸŽ€


🌸 NAME 🌸

__kmemdup_nul β€” creates a NUL-terminated string from @s, which might be unterminated 😱

like, @s might just rawdog its way to the end with no \0 in sight, and this function is the one that shows up with a little terminator for her 🫢


✨ SYNOPSIS ✨

char * __kmemdup_nul (const char *s , size_t len , gfp_t gfp );

that's the whole vibe check right there πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • s β€” the data to copy. literally the payload, the main character, the whole reason we're here πŸ‘‘
  • len β€” the size of the data, and no bestie, this does not include the NUL terminator, so don't be out here counting her πŸ™ˆ
  • gfp β€” the GFP mask used in the kmalloc call when allocating memory. it's giving "how do you want this allocation to go down" energy ⭐

πŸ’œ RETURN πŸ’œ

you get back a newly allocated copy of s with NUL-termination β€” slay πŸŽ‰ β€” or NULL in case of error 😭 so like, check your return values, fr fr, no cap, this is the moment where NULL checks are non-negotiable πŸ’€


🌈 SEE ALSO 🌈

ok so this is the friend group, everybody's tagged 🫢

Kernel file ./mm/util.c

then, in the order the manpage hands them to us, no reshuffling, no skipping:

πŸ’‘ no seriously, that's all of them, don't @ me, I didn't invent a single one and I didn't drop a single one either πŸ”₯

and that's the page, bestie! πŸ’… tiny little note before I go β€” this one lives in the ./mm section, dated October 2026, and it's filed under the header __kmemdup_nul(9) in the <purple>Kernel API Manual</purple>. go forth and terminate your strings properly, mwah πŸ˜˜πŸŽ€βœ¨

πŸ“¦ where this page comes from