Skip to content

Commit f3f380c

Browse files
kaushlenbroonie
authored andcommitted
regmap: maple: free entry on mas_store_gfp() failure
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> Link: https://patch.msgid.link/20260105031820.260119-1-kaushlendra.kumar@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 9ace475 commit f3f380c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

drivers/base/regmap/regcache-maple.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,
9595

9696
mas_unlock(&mas);
9797

98-
if (ret == 0) {
99-
kfree(lower);
100-
kfree(upper);
98+
if (ret) {
99+
kfree(entry);
100+
return ret;
101101
}
102-
103-
return ret;
102+
kfree(lower);
103+
kfree(upper);
104+
return 0;
104105
}
105106

106107
static int regcache_maple_drop(struct regmap *map, unsigned int min,

0 commit comments

Comments
 (0)