[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1459234412-27192-1-git-send-email-alexander.stein@systec-electronic.com>
Date: Tue, 29 Mar 2016 08:53:32 +0200
From: Alexander Stein <alexander.stein@...tec-electronic.com>
To: Mark Brown <broonie@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Alexander Stein <alexander.stein@...tec-electronic.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/1] regcache: flat: Require max_registers to be set
If max_register is unset, regcache_flat_get_index will return 0 and only
memory for 1 unsigned int will be allocated, resulting in writing out
of bounds.
Signed-off-by: Alexander Stein <alexander.stein@...tec-electronic.com>
---
drivers/base/regmap/regcache-flat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c
index 3ee7255..4d2e50b 100644
--- a/drivers/base/regmap/regcache-flat.c
+++ b/drivers/base/regmap/regcache-flat.c
@@ -27,7 +27,7 @@ static int regcache_flat_init(struct regmap *map)
int i;
unsigned int *cache;
- if (!map || map->reg_stride_order < 0)
+ if (!map || map->reg_stride_order < 0 || !map->max_register)
return -EINVAL;
map->cache = kcalloc(regcache_flat_get_index(map, map->max_register)
--
2.7.3
Powered by blists - more mailing lists