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 7, 2012
1 parent 9878647 commit 851960b
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 @@ -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);
Expand Down Expand Up @@ -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 ||
Expand Down

0 comments on commit 851960b

Please sign in to comment.