Skip to contentSkip to conversation

Patch "regmap: regcache-rbtree: Clean new present bits on present bitmap resize" has been added to the 3.14-stable tree

PATCH [email protected] 1 participant 1 message Sep 11, 2015

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

regmap: regcache-rbtree: Clean new present bits on present bitmap resize

to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
regmap-regcache-rbtree-clean-new-present-bits-on-present-bitmap-resize.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 8ef9724bf9718af81cfc5132253372f79c71b7e2 Mon Sep 17 00:00:00 2001

From: Guenter Roeck <[email protected]>
Date: Sun, 26 Jul 2015 21:34:50 -0700
Subject: regmap: regcache-rbtree: Clean new present bits on present bitmap resize

From: Guenter Roeck <[email protected]>

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")
---
 drivers/base/regmap/regcache-rbtree.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/base/regmap/regcache-rbtree.c +14 -5
@@ -302,11 +302,20 @@ static int regcache_rbtree_insert_to_blo
 	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 */

Patches currently in stable-queue which might be from [email protected] are

queue-3.14/regmap-regcache-rbtree-clean-new-present-bits-on-present-bitmap-resize.patch