Commit 6e4f2878 authored by Alexander Stein's avatar Alexander Stein Committed by Mark Brown

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: default avatarAlexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent f55532a0
...@@ -27,7 +27,7 @@ static int regcache_flat_init(struct regmap *map) ...@@ -27,7 +27,7 @@ static int regcache_flat_init(struct regmap *map)
int i; int i;
unsigned int *cache; unsigned int *cache;
if (!map || map->reg_stride_order < 0) if (!map || map->reg_stride_order < 0 || !map->max_register)
return -EINVAL; return -EINVAL;
map->cache = kcalloc(regcache_flat_get_index(map, map->max_register) map->cache = kcalloc(regcache_flat_get_index(map, map->max_register)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment