kfree_const(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kfree_const(9) β€” from the Kernel API Manual, bestie

Okay so picture this: you're deep in kfree_const(9) territory, the Kernel API Manual has your back, and I'm here to translate. Let's go ✨


🌸 NAME

kfree_const β€” freeing memory, but conditionally. It's giving "read the room before you act" energy fr fr.


πŸŽ€ SYNOPSIS

void kfree_const (const void *x );

That's it. That's the whole vibe check. πŸ‘‘


πŸ¦‹ ARGUMENTS

  • x β€” pointer to the memory πŸ‘‰ literally just the address of the stuff you're thinking about freeing. Nothing more, nothing less.

πŸ’– DESCRIPTION

So here's the tea β˜•: this function calls kfree only if x is not in the .rodata section.

That's the whole personality. No .rodata shenanigans, no free. It's lowkey the most responsible little function in the kernel β€” checks first, frees second. Slay. 🧚


πŸ”₯ SEE ALSO

Kernel file ./mm/util.c β€” and the whole friend group, no cap:

__kmemdup_nul(9), kstrdup(9), kstrdup_const(9), kstrndup(9), kmemdup(9), kmemdup_array(9), kvmemdup(9), kmemdup_nul(9), memdup_user(9), vmemdup_user(9), strndup_user(9), memdup_user_nul(9), randomize_page(9), __account_locked_vm(9), account_locked_vm(9), __vmalloc_array(9), vmalloc_array(9), __vcalloc(9), vcalloc(9), folio_mapping(9), folio_copy(9), get_cmdline(9), mem_dump_obj(9), compat_set_desc_from_vma(9), __compat_vma_mmap(9), compat_vma_mmap(9), snapshot_page(9), mmap_action_prepare(9), mmap_action_complete(9), folio_pte_batch(9), page_range_contiguous(9)

That's the entire squad and yes we're tagging everyone. πŸ’€


Kiss kiss, this page lives in ./mm, stamped October 2026 β€” see you in the next manpage bestie, mwah πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from