Skip to content

Commit 851960b

Browse files
nvswarrenbroonie
authored andcommitted
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 <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 9878647 commit 851960b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/base/regmap/regmap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
595595
{
596596
int ret;
597597

598+
if (val_len % map->format.val_bytes)
599+
return -EINVAL;
600+
598601
map->lock(map);
599602

600603
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,
753756
unsigned int v;
754757
int ret, i;
755758

759+
if (val_len % map->format.val_bytes)
760+
return -EINVAL;
761+
756762
map->lock(map);
757763

758764
if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass ||

0 commit comments

Comments
 (0)