2013-08-21 15:37:19

by David Jander

[permalink] [raw]
Subject: [PATCH V2] drivers: regmap: regcache-rbtree.c: Fix overlapping rbnodes.

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 <[email protected]>
---
drivers/base/regmap/regcache-rbtree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index 5c1435c..0fccc99 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -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;
}

--
1.8.1.2


2013-08-21 16:11:05

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH V2] drivers: regmap: regcache-rbtree.c: Fix overlapping rbnodes.

On Wed, Aug 21, 2013 at 05:37:22PM +0200, David Jander wrote:
> 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.

Applied, thanks.


Attachments:
(No filename) (634.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments