summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/base/regmap
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/base/regmap')
-rw-r--r--kernel/drivers/base/regmap/regcache-rbtree.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/kernel/drivers/base/regmap/regcache-rbtree.c b/kernel/drivers/base/regmap/regcache-rbtree.c
index 81751a49d..56486d92c 100644
--- a/kernel/drivers/base/regmap/regcache-rbtree.c
+++ b/kernel/drivers/base/regmap/regcache-rbtree.c
@@ -296,11 +296,20 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
if (!blk)
return -ENOMEM;
- present = krealloc(rbnode->cache_present,
- BITS_TO_LONGS(blklen) * sizeof(*present), GFP_KERNEL);
- if (!present) {
- kfree(blk);
- return -ENOMEM;
+ if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) {
+ present = krealloc(rbnode->cache_present,
+ BITS_TO_LONGS(blklen) * sizeof(*present),
+ GFP_KERNEL);
+ if (!present) {
+ kfree(blk);
+ return -ENOMEM;
+ }
+
+ memset(present + BITS_TO_LONGS(rbnode->blklen), 0,
+ (BITS_TO_LONGS(blklen) - BITS_TO_LONGS(rbnode->blklen))
+ * sizeof(*present));
+ } else {
+ present = rbnode->cache_present;
}
/* insert the register value in the correct place in the rbnode block */