aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-04-06 17:16:03 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-07 04:27:04 -0400
commit851960ba7cb38a6a108d102e4c8b0ab702972e22 (patch)
tree0af40ec3a92921077f71a2f8b703f64eb0eb322f /drivers
parent9878647f4349dbaa46b4026ed9bbf8acfc0de34c (diff)
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 <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/regmap.c6
1 files changed, 6 insertions, 0 deletions
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,
595{ 595{
596 int ret; 596 int ret;
597 597
598 if (val_len % map->format.val_bytes)
599 return -EINVAL;
600
598 map->lock(map); 601 map->lock(map);
599 602
600 ret = _regmap_raw_write(map, reg, val, val_len); 603 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,
753 unsigned int v; 756 unsigned int v;
754 int ret, i; 757 int ret, i;
755 758
759 if (val_len % map->format.val_bytes)
760 return -EINVAL;
761
756 map->lock(map); 762 map->lock(map);
757 763
758 if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass || 764 if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass ||