Patch "regmap: rbtree: Fix wrong register marked as in-cache when creating new node" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    regmap: rbtree: Fix wrong register marked as in-cache when creating new node

to the 5.10-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-rbtree-fix-wrong-register-marked-as-in-cache-.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9878ad967443a12f3801ce464df82e9c8b3e7d7c
Author: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
Date:   Fri Sep 22 16:37:11 2023 +0100

    regmap: rbtree: Fix wrong register marked as in-cache when creating new node
    
    [ Upstream commit 7a795ac8d49e2433e1b97caf5e99129daf8e1b08 ]
    
    When regcache_rbtree_write() creates a new rbtree_node it was passing the
    wrong bit number to regcache_rbtree_set_register(). The bit number is the
    offset __in number of registers__, but in the case of creating a new block
    regcache_rbtree_write() was not dividing by the address stride to get the
    number of registers.
    
    Fix this by dividing by map->reg_stride.
    Compare with regcache_rbtree_read() where the bit is checked.
    
    This bug meant that the wrong register was marked as present. The register
    that was written to the cache could not be read from the cache because it
    was not marked as cached. But a nearby register could be marked as having
    a cached value even if it was never written to the cache.
    
    Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
    Fixes: 3f4ff561bc88 ("regmap: rbtree: Make cache_present bitmap per node")
    Link: https://lore.kernel.org/r/20230922153711.28103-1-rf@xxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index ae6b8788d5f3f..d65715b9e129e 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -453,7 +453,8 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
 		if (!rbnode)
 			return -ENOMEM;
 		regcache_rbtree_set_register(map, rbnode,
-					     reg - rbnode->base_reg, value);
+					     (reg - rbnode->base_reg) / map->reg_stride,
+					     value);
 		regcache_rbtree_insert(map, &rbtree_ctx->root, rbnode);
 		rbtree_ctx->cached_rbnode = rbnode;
 	}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux