]> git.karo-electronics.de Git - linux-beck.git/commitdiff
regmap: Fix 'ret' would return an uninitialized value
authorCai Zhiyong <caizhiyong@huawei.com>
Mon, 18 Nov 2013 12:21:49 +0000 (20:21 +0800)
committerMark Brown <broonie@linaro.org>
Sun, 24 Nov 2013 13:59:14 +0000 (13:59 +0000)
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>
drivers/base/regmap/regmap.c

index 9c021d9cace0fcc74080ccec7b5a2b3933c65f2a..9a36ac14b0b5d1ac1f231284d04040d99782da75 100644 (file)
@@ -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;