[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1333746963-6793-1-git-send-email-swarren@wwwdotorg.org>
Date: Fri, 6 Apr 2012 15:16:03 -0600
From: Stephen Warren <swarren@...dotorg.org>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc: linux-kernel@...r.kernel.org, Stephen Warren <swarren@...dia.com>
Subject: [PATCH] regmap: validate regmap_raw_read/write val_len
From: Stephen Warren <swarren@...dia.com>
val_len should be a multiple of val_bytes. If it's not, error out early.
Signed-off-by: Stephen Warren <swarren@...dia.com>
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists