[PATCH] regmap: validate regmap_raw_read/write val_len

From: Stephen Warren
Date: Fri Apr 06 2012 - 17:16:09 EST


From: Stephen Warren <swarren@xxxxxxxxxx>

val_len should be a multiple of val_bytes. If it's not, error out early.

Signed-off-by: Stephen Warren <swarren@xxxxxxxxxx>
---
Mark, these checks are currently implemented in regmap-mmio.c. In a second,
I'll send a patch to remove them from there.

drivers/base/regmap/regmap.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 2b5e7ae..40f9101 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -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);
@@ -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 ||
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/