mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] regcache: Do not overwrite error code when finalizing cache after error
@ 2026-06-17  6:22 Francesco Lavra
  2026-06-17  7:00 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Francesco Lavra @ 2026-06-17  6:22 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki,
	Danilo Krummrich, Charles Keepax, Andy Shevchenko, linux-kernel,
	driver-core
  Cc: stable

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>
Cc: stable@kernel.org
---
Changes from v1 [1]:
- added stable tag to commit message

[1] https://lore.kernel.org/driver-core/20260616114429.1852456-1-flavra@baylibre.com/T/

 drivers/base/regmap/regcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 27616b05111c..aa8f2efed779 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -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:
-- 
2.39.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] regcache: Do not overwrite error code when finalizing cache after error
  2026-06-17  6:22 [PATCH v2] regcache: Do not overwrite error code when finalizing cache after error Francesco Lavra
@ 2026-06-17  7:00 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2026-06-17  7:00 UTC (permalink / raw)
  To: Francesco Lavra
  Cc: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki,
	Danilo Krummrich, Charles Keepax, linux-kernel, driver-core,
	stable

On Wed, Jun 17, 2026 at 08:22:28AM +0200, Francesco Lavra wrote:
> 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.

Too quick to send.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
as per v1.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-17  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17  6:22 [PATCH v2] regcache: Do not overwrite error code when finalizing cache after error Francesco Lavra
2026-06-17  7:00 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®