regmap: regcache-rbtree: Clean new present bits on present bitmap resize
authorGuenter Roeck <linux@roeck-us.net>
Mon, 27 Jul 2015 04:34:50 +0000 (21:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 16:07:44 +0000 (09:07 -0700)
commitfd1090c256f53c12d3840056a15112264ee26c0a
tree98e8ada3c35063996b900502951ffb68093259be
parent1cc4bf08d789b5daf679244d93f4adebb19ff64d
regmap: regcache-rbtree: Clean new present bits on present bitmap resize

commit 8ef9724bf9718af81cfc5132253372f79c71b7e2 upstream.

When inserting a new register into a block, the present bit map size is
increased using krealloc. krealloc does not clear the additionally
allocated memory, leaving it filled with random values. Result is that
some registers are considered cached even though this is not the case.

Fix the problem by clearing the additionally allocated memory. Also, if
the bitmap size does not increase, do not reallocate the bitmap at all
to reduce overhead.

Fixes: 3f4ff561bc88 ("regmap: rbtree: Make cache_present bitmap per node")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/regmap/regcache-rbtree.c