瀏覽代碼

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>
Mark Brown 10 年之前
父節點
當前提交
fa3eec7791
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      drivers/base/regmap/regmap.c

+ 2 - 0
drivers/base/regmap/regmap.c

@@ -2180,6 +2180,8 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
 		return -EINVAL;
 		return -EINVAL;
 	if (reg % map->reg_stride)
 	if (reg % map->reg_stride)
 		return -EINVAL;
 		return -EINVAL;
+	if (val_count == 0)
+		return -EINVAL;
 
 
 	map->lock(map->lock_arg);
 	map->lock(map->lock_arg);