Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd60e381 authored by Cai Zhiyong's avatar Cai Zhiyong Committed by Mark Brown
Browse files

regmap: Fix 'ret' would return an uninitialized value



This patch give a warning when calling regmap_register_patch with
parameter num_regs <= 0.

When the num_regs parameter is zero and krealloc doesn't fail,
then the code would return an uninitialized value. However,
calling this function with num_regs == 0, would be a waste as it
essentially does nothing.

Signed-off-by: default avatarCai Zhiyong <caizhiyong@huawei.com>
Reviewed-by: default avatarGeyslan G. Bem <geyslan@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 6ce4eac1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2173,6 +2173,10 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
	int i, ret;
	bool bypass;

	if (WARN_ONCE(num_regs <= 0, "invalid registers number (%d)\n",
	    num_regs))
		return 0;

	map->lock(map->lock_arg);

	bypass = map->cache_bypass;