mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-10-29 11:06:29 +08:00
assoc_array.rst says the level passed to get_key_chunk() will be a multiple of ASSOC_ARRAY_KEY_CHUNK_SIZE, and asks for the chunk starting at that bit. assoc_array_walk() after a shortcut, and both insertion paths, pass the level of a node, which is any multiple of 4. Each then shifts the chunk it gets back right by level & ASSOC_ARRAY_KEY_CHUNK_MASK, so what it wants is the chunk that contains that bit. The keyring code copes, because keyring_get_key_chunk() divides the level by ASSOC_ARRAY_KEY_CHUNK_SIZE before using it. An implementation written to the documentation does not: one that returns a one-word key for level 0 and nothing for any other level files leaves under the wrong slot the first time a node is split, and a later insertion hits the BUG_ON() after found_slot_for_multiple_occupancy in assoc_array_insert_into_terminal_node(). Say what the code expects. get_object_key_chunk() is documented as "the previous function", so this covers it too. Assisted-by: LLM Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>