diff options
author | Cai Zhiyong <caizhiyong@huawei.com> | 2013-11-18 13:21:49 +0100 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-11-24 14:59:14 +0100 |
commit | bd60e381fab88979c3312265d18bb635c314d242 (patch) | |
tree | 7f0d6878610b05f49a6414a943b9fa4118d40f23 /drivers/base/regmap/regmap.c | |
parent | Linux 3.13-rc1 (diff) | |
download | linux-bd60e381fab88979c3312265d18bb635c314d242.tar.xz linux-bd60e381fab88979c3312265d18bb635c314d242.zip |
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: Cai Zhiyong <caizhiyong@huawei.com>
Reviewed-by: Geyslan G. Bem <geyslan@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base/regmap/regmap.c')
-rw-r--r-- | drivers/base/regmap/regmap.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 9c021d9cace0..9a36ac14b0b5 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -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; |