Unverified Commit f3f380ce authored by Kaushlendra Kumar's avatar Kaushlendra Kumar Committed by Mark Brown
Browse files

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: default avatarKaushlendra Kumar <kaushlendra.kumar@intel.com>
Link: https://patch.msgid.link/20260105031820.260119-1-kaushlendra.kumar@intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9ace4753
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -95,12 +95,13 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,

	mas_unlock(&mas);

	if (ret == 0) {
	if (ret) {
		kfree(entry);
		return ret;
	}
	kfree(lower);
	kfree(upper);
	}
	
	return ret;
	return 0;
}

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