mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 15:04:27 +08:00
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>
This commit is contained in:
parent
f55532a0c0
commit
6e4f28780f
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user