]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
regcache: Do not overwrite error code when finalizing cache after error
authorFrancesco Lavra <flavra@baylibre.com>
Tue, 16 Jun 2026 11:44:29 +0000 (13:44 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 16 Jun 2026 13:13:48 +0000 (14:13 +0100)
During regcache initialization, if an error occurs in the
cache_ops->populate callback, and if cache operations include an exit
callback, the error code from populate() is overwritten with the return
value from exit(). This hides the error condition from the caller of
regcache_init(), and can cause NULL pointer dereferences when the regcache
is later accessed.

Fixes: 94a3a95f0315 ("regcache: Add ->populate() callback to separate from ->init()")
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Link: https://patch.msgid.link/20260616114429.1852456-1-flavra@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regcache.c

index 27616b05111cc7429c33295be56befe21de17455..aa8f2efed7798d1df3f4c9c1eb80837c2076968f 100644 (file)
@@ -245,7 +245,7 @@ err_exit:
        if (map->cache_ops->exit) {
                dev_dbg(map->dev, "Destroying %s cache\n", map->cache_ops->name);
                map->lock(map->lock_arg);
-               ret = map->cache_ops->exit(map);
+               map->cache_ops->exit(map);
                map->unlock(map->lock_arg);
        }
 err_free_reg_defaults: