From: Stephen Warren Date: Fri, 6 Apr 2012 21:16:03 +0000 (-0600) Subject: regmap: validate regmap_raw_read/write val_len X-Git-Tag: next-20120411~19^2^2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=851960ba7cb38a6a108d102e4c8b0ab702972e22;p=karo-tx-linux.git regmap: validate regmap_raw_read/write val_len val_len should be a multiple of val_bytes. If it's not, error out early. Signed-off-by: Stephen Warren Signed-off-by: Mark Brown --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 6b4a775b439b..ee4fea351220 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -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 ||