regcache: Do not overwrite error code when finalizing cache after error
Subsystems (2)
PATCH v2 1/1 regcache: Do not overwrite error code when finalizing cache after error
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.
---
Changes from v1 [1]:
- added stable tag to commit message
[1] https://lore.kernel.org/driver-core/[email protected]/T/
drivers/base/regmap/regcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regcache.c +1 -1
@@ -245,7 +245,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)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:
Signature · 1 line
2.39.5
Quoted 6 lines · Francesco Lavra
During regcache initialization, if an error occurs in the
cache_ops->populatecallback, and if cache operations include an exit callback, the error code frompopulate()is overwritten with the return value fromexit(). This hides the error condition from the caller ofregcache_init(), and can cause NULL pointer dereferences when the regcache is later accessed.
Too quick to send.
as per v1.
Signature · 2 lines
With Best Regards, Andy Shevchenko