lkml.org 
[lkml]   [2012]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] regmap: validate regmap_raw_read/write val_len
Date
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


\
 
 \ /
  Last update: 2012-04-06 23:19    [W:0.032 / U:1.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site