Skip to content

Commit

Permalink
regmap: validate regmap_raw_read/write val_len
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Warren authored and Mark Brown committed Apr 13, 2012
1 parent 8664d49 commit 2690dfd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,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);
Expand Down Expand Up @@ -779,6 +782,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 ||
Expand Down

0 comments on commit 2690dfd

Please sign in to comment.