regmap: validate regmap_raw_read/write val_len
authorStephen Warren <swarren@nvidia.com>
Fri, 6 Apr 2012 21:16:03 +0000 (15:16 -0600)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sat, 7 Apr 2012 08:27:04 +0000 (09:27 +0100)
val_len should be a multiple of val_bytes. If it's not, error out early.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/base/regmap/regmap.c

index 6b4a775b439b1635895883cef5c291908250d2c0..ee4fea351220447a514b6b30731f44d7c5f94b5b 100644 (file)
@@ -595,6 +595,9 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
 {
        int ret;
 
+       if (val_len % map->format.val_bytes)
+               return -EINVAL;
+
        map->lock(map);
 
        ret = _regmap_raw_write(map, reg, val, val_len);
@@ -753,6 +756,9 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
        unsigned int v;
        int ret, i;
 
+       if (val_len % map->format.val_bytes)
+               return -EINVAL;
+
        map->lock(map);
 
        if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass ||