diff options
author | Alexander Stein <alexander.stein@systec-electronic.com> | 2016-03-29 02:53:32 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-29 12:51:04 -0400 |
commit | 6e4f28780f38e27cb7ca0edeb1d7ebb4edfd1fc5 (patch) | |
tree | 781ef0c6f3796dd94b56009cb09cbd8f669fc0ee | |
parent | f55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff) |
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@systec-electronic.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/base/regmap/regcache-flat.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c index 3ee72550b1e3..4d2e50bfc726 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) | |||
27 | int i; | 27 | int i; |
28 | unsigned int *cache; | 28 | unsigned int *cache; |
29 | 29 | ||
30 | if (!map || map->reg_stride_order < 0) | 30 | if (!map || map->reg_stride_order < 0 || !map->max_register) |
31 | return -EINVAL; | 31 | return -EINVAL; |
32 | 32 | ||
33 | map->cache = kcalloc(regcache_flat_get_index(map, map->max_register) | 33 | map->cache = kcalloc(regcache_flat_get_index(map, map->max_register) |