Commit cec45d90 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regmap-fix-v4.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull regmap fix from Mark Brown:
 "regmap: Fix handling of present bits on rbtree cache block resize

  When expanding a cache block we use krealloc() to resize the register
  present bitmap without initialising the newly allocated data (the
  original code was written for kzalloc()).  Add an appropraite memset()
  to fix that"

* tag 'regmap-fix-v4.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
  regmap: regcache-rbtree: Clean new present bits on present bitmap resize
parents 58ccab91 8ef9724b
...@@ -296,11 +296,20 @@ static int regcache_rbtree_insert_to_block(struct regmap *map, ...@@ -296,11 +296,20 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
if (!blk) if (!blk)
return -ENOMEM; return -ENOMEM;
present = krealloc(rbnode->cache_present, if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) {
BITS_TO_LONGS(blklen) * sizeof(*present), GFP_KERNEL); present = krealloc(rbnode->cache_present,
if (!present) { BITS_TO_LONGS(blklen) * sizeof(*present),
kfree(blk); GFP_KERNEL);
return -ENOMEM; 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 */ /* insert the register value in the correct place in the rbnode block */
......
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