* [PATCH] regcache: Do not overwrite error code when finalizing cache after error
@ 2026-06-16 11:44 Francesco Lavra
2026-06-16 11:54 ` Greg Kroah-Hartman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Francesco Lavra @ 2026-06-16 11:44 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Charles Keepax, Andy Shevchenko, linux-kernel,
driver-core
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>
---
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] 4+ messages in thread
* Re: [PATCH] regcache: Do not overwrite error code when finalizing cache after error
2026-06-16 11:44 [PATCH] regcache: Do not overwrite error code when finalizing cache after error Francesco Lavra
@ 2026-06-16 11:54 ` Greg Kroah-Hartman
2026-06-16 13:15 ` Mark Brown
2026-06-17 6:56 ` Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-06-16 11:54 UTC (permalink / raw)
To: Francesco Lavra
Cc: Mark Brown, Rafael J. Wysocki, Danilo Krummrich, Charles Keepax,
Andy Shevchenko, linux-kernel, driver-core
On Tue, Jun 16, 2026 at 01:44:29PM +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.
>
> Fixes: 94a3a95f0315 ("regcache: Add ->populate() callback to separate from ->init()")
> Signed-off-by: Francesco Lavra <flavra@baylibre.com>
> ---
> 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
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] regcache: Do not overwrite error code when finalizing cache after error
2026-06-16 11:44 [PATCH] regcache: Do not overwrite error code when finalizing cache after error Francesco Lavra
2026-06-16 11:54 ` Greg Kroah-Hartman
@ 2026-06-16 13:15 ` Mark Brown
2026-06-17 6:56 ` Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-06-16 13:15 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Charles Keepax, Andy Shevchenko, linux-kernel, driver-core,
Francesco Lavra
On Tue, 16 Jun 2026 13:44:29 +0200, Francesco Lavra wrote:
> regcache: Do not overwrite error code when finalizing cache after error
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-7.2
Thanks!
[1/1] regcache: Do not overwrite error code when finalizing cache after error
https://git.kernel.org/broonie/regmap/c/9108f7fa493b
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] regcache: Do not overwrite error code when finalizing cache after error
2026-06-16 11:44 [PATCH] regcache: Do not overwrite error code when finalizing cache after error Francesco Lavra
2026-06-16 11:54 ` Greg Kroah-Hartman
2026-06-16 13:15 ` Mark Brown
@ 2026-06-17 6:56 ` Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-06-17 6:56 UTC (permalink / raw)
To: Francesco Lavra
Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Charles Keepax, linux-kernel, driver-core
On Tue, Jun 16, 2026 at 01:44:29PM +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.
Ah, good catch!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-17 13:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-16 11:44 [PATCH] regcache: Do not overwrite error code when finalizing cache after error Francesco Lavra
2026-06-16 11:54 ` Greg Kroah-Hartman
2026-06-16 13:15 ` Mark Brown
2026-06-17 6:56 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox