regmap: Silence warning on invalid zero length read
authorMark Brown <broonie@kernel.org>
Wed, 1 Jul 2015 22:51:43 +0000 (23:51 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 14 Jul 2015 10:23:08 +0000 (11:23 +0100)
Zero length reads make no sense in a regmap context and are likely to
trigger bugs further down the stack so insert an error check, also
silencing compiler warnings about use of ret in cases where we iterate
per register.

Reported-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap.c

index 8894b99..9c1f856 100644 (file)
@@ -2180,6 +2180,8 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
                return -EINVAL;
        if (reg % map->reg_stride)
                return -EINVAL;
+       if (val_count == 0)
+               return -EINVAL;
 
        map->lock(map->lock_arg);