aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2015-07-01 23:51:43 +0100
committerMark Brown <broonie@kernel.org>2015-07-14 11:23:08 +0100
commitfa3eec7791b0fe27e3112804a71ba445ff336a6b (patch)
tree770834b4226186039a7227e71ccd877b8dd7c82a /drivers/base/regmap
parentregmap: Add better support for devices without readback support (diff)
downloadlinux-dev-fa3eec7791b0fe27e3112804a71ba445ff336a6b.tar.xz
linux-dev-fa3eec7791b0fe27e3112804a71ba445ff336a6b.zip
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 <rmk+kernel@arm.linux.org.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r--drivers/base/regmap/regmap.c2
1 files changed, 2 insertions, 0 deletions
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);