From: Mark Brown Date: Wed, 1 Jul 2015 22:51:43 +0000 (+0100) Subject: regmap: Silence warning on invalid zero length read X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fa3eec7791b0fe27e3112804a71ba445ff336a6b;p=linux-beck.git regmap: Silence warning on invalid zero length read 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 Signed-off-by: Mark Brown --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 8894b992043e..9c1f856842a3 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -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);