Skip to content

Commit

Permalink
regmap: rbtree: Fix overlapping rbnodes.
Browse files Browse the repository at this point in the history
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: David Jander <david@protonic.nl>
Signed-off-by: Mark Brown <broonie@linaro.org>
Cc: stable@vger.kernel.org
  • Loading branch information
David Jander authored and Mark Brown committed Aug 21, 2013
1 parent b36f4be commit 4e67fb5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/regmap/regcache-rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg)
}

if (!rbnode->blklen) {
rbnode->blklen = sizeof(*rbnode);
rbnode->blklen = 1;
rbnode->base_reg = reg;
}

Expand Down

0 comments on commit 4e67fb5

Please sign in to comment.