提交 bd60e381 编写于 作者: C Cai Zhiyong 提交者: Mark Brown

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: NCai Zhiyong <caizhiyong@huawei.com>
Reviewed-by: NGeyslan G. Bem <geyslan@gmail.com>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 6ce4eac1
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册