Commit 0c6471cc authored by David Jander's avatar David Jander Committed by Greg Kroah-Hartman
Browse files

regmap: rbtree: Fix overlapping rbnodes.

commit 4e67fb5f


Avoid overlapping register regions by making the initial blklen of a new
node 1. If a register write occurs to a yet uncached register, that is
lower than but near an existing node's base_reg, a new node is created
and it's blklen is set to an arbitrary value (sizeof(*rbnode)). That may
cause this node to overlap with another node. Those nodes should be merged,
but this merge doesn't happen yet, so this patch at least makes the initial
blklen small enough to avoid hitting the wrong node, which may otherwise
lead to severe breakage.
Signed-off-by: default avatarDavid Jander <>
Signed-off-by: default avatarMark Brown <>
Signed-off-by: default avatarZhouping Liu <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 2ac13a8f
......@@ -362,7 +362,7 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
rbnode = kzalloc(sizeof *rbnode, GFP_KERNEL);
if (!rbnode)
return -ENOMEM;
rbnode->blklen = sizeof(*rbnode);
rbnode->blklen = 1;
rbnode->base_reg = reg;
rbnode->block = kmalloc(rbnode->blklen * map->cache_word_size,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment