Skip to content

Commit eab5abd

Browse files
committed
regmap: Check for register readability before checking cache during read
Ensure that we don't return a spurious cache hit for unreadable registers (eg, with the flat cache which doesn't understand sparseness) by checking for readability before we do a cache lookup. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230613-b4-regmap-check-readability-before-cache-v1-1-b144c0b01ed9@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b629c69 commit eab5abd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/base/regmap/regmap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,6 +2897,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
28972897
int ret;
28982898
void *context = _regmap_map_get_context(map);
28992899

2900+
if (!regmap_readable(map, reg))
2901+
return -EIO;
2902+
29002903
if (!map->cache_bypass) {
29012904
ret = regcache_read(map, reg, val);
29022905
if (ret == 0)
@@ -2906,9 +2909,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
29062909
if (map->cache_only)
29072910
return -EBUSY;
29082911

2909-
if (!regmap_readable(map, reg))
2910-
return -EIO;
2911-
29122912
ret = map->reg_read(context, reg, val);
29132913
if (ret == 0) {
29142914
if (regmap_should_log(map))

0 commit comments

Comments
 (0)