Messages in this thread Patch in this message | | | From | Stephen Warren <> | Subject | [PATCH] regmap: validate regmap_raw_read/write val_len | Date | Fri, 6 Apr 2012 15:16:03 -0600 |
| |
From: Stephen Warren <swarren@nvidia.com>
val_len should be a multiple of val_bytes. If it's not, error out early.
Signed-off-by: Stephen Warren <swarren@nvidia.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
| |