* [PATCH] regmap: maple: free entry on mas_store_gfp() failure
@ 2026-01-05 3:18 Kaushlendra Kumar
2026-01-06 12:21 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Kaushlendra Kumar @ 2026-01-05 3:18 UTC (permalink / raw)
To: broonie, gregkh, rafael, dakr; +Cc: linux-kernel, Kaushlendra Kumar
regcache_maple_write() allocates a new block ('entry') to merge
adjacent ranges and then stores it with mas_store_gfp().
When mas_store_gfp() fails, the new 'entry' remains allocated and
is never freed, leaking memory.
Free 'entry' on the failure path; on success continue freeing the
replaced neighbor blocks ('lower', 'upper').
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
drivers/base/regmap/regcache-maple.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c
index ca1c72b68f31..4134a77ae1d6 100644
--- a/drivers/base/regmap/regcache-maple.c
+++ b/drivers/base/regmap/regcache-maple.c
@@ -95,12 +95,13 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,
mas_unlock(&mas);
- if (ret == 0) {
- kfree(lower);
- kfree(upper);
+ if (ret) {
+ kfree(entry);
+ return ret;
}
-
- return ret;
+ kfree(lower);
+ kfree(upper);
+ return 0;
}
static int regcache_maple_drop(struct regmap *map, unsigned int min,
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] regmap: maple: free entry on mas_store_gfp() failure
2026-01-05 3:18 [PATCH] regmap: maple: free entry on mas_store_gfp() failure Kaushlendra Kumar
@ 2026-01-06 12:21 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-01-06 12:21 UTC (permalink / raw)
To: gregkh, rafael, dakr, Kaushlendra Kumar; +Cc: linux-kernel
On Mon, 05 Jan 2026 08:48:20 +0530, Kaushlendra Kumar wrote:
> regcache_maple_write() allocates a new block ('entry') to merge
> adjacent ranges and then stores it with mas_store_gfp().
> When mas_store_gfp() fails, the new 'entry' remains allocated and
> is never freed, leaking memory.
>
> Free 'entry' on the failure path; on success continue freeing the
> replaced neighbor blocks ('lower', 'upper').
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/1] regmap: maple: free entry on mas_store_gfp() failure
commit: f3f380ce6b3d5c9805c7e0b3d5bc28d9ec41e2e8
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] 2+ messages in thread
end of thread, other threads:[~2026-01-06 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-05 3:18 [PATCH] regmap: maple: free entry on mas_store_gfp() failure Kaushlendra Kumar
2026-01-06 12:21 ` Mark Brown
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®