binder_get_...node_olocked(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– binder_get_ref_for_node_olocked(9) πŸ’–

okay so this is a page from the Kernel API Manual and bestie, it's literally about getting the ref that goes with a given node. lock in, we're doing this 🫢


✨ NAME ✨

binder_get_ref_for_node_olocked β€” get the ref associated with given node


🌸 SYNOPSIS 🌸

struct binder_ref * binder_get_ref_for_node_olocked (struct binder_proc
*proc , struct binder_node *node , struct binder_ref *new_ref );

like, that's the whole signature, no cap. three args, one struct pointer coming back at you πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • proc β€” the binder_proc that owns the ref. it's giving "this is my ref, i own it" energy πŸ‘‘
  • node β€” the binder_node of target. the thing we're actually looking for, the main character fr
  • new_ref β€” a newly allocated binder_ref that's gonna get initialized, or NULL. your call, bestie πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

so first thing it does: it looks up the ref for the given node, and if it exists? it just returns it. easy. slay. ✨

but if it doesn't exist and the caller was nice enough to hand over a newly allocated ref, then it initializes the fields of that newly allocated ref and inserts it into the given proc rb_trees and the node refs list. two places, one insert, iconic behaviour honestly πŸ”₯


⭐ RETURN ⭐

it returns the ref for node. πŸ‘‘

but here's the plot twist β€” and this is important, ngl β€” it is possible that another thread allocated/initialized the ref first. in that case, the returned ref would be different than the passed-in new_ref.

⚠️ and in that case, new_ref must be kfree'd by the caller. no leaking, we don't do that here πŸ’€ please free your refs bestie 😭

🌈 SEE ALSO 🌈

Kernel file ./drivers/android/binder.c β€” and now the whole friend group, in the order they were introduced 🫢:


anyway that's the whole page πŸ’œ love that for us. this one lives over in ./drivers/android and the version/date stamp says October 2026 β€” so yeah, future vibes only 🧚✨ bye bestie, go free your new_ref πŸ“πŸ’…

πŸ“¦ where this page comes from