Skip to content

Commit

Permalink
regcache: flat: Require max_registers to be set
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexander Stein authored and Mark Brown committed Mar 29, 2016
1 parent f55532a commit 6e4f287
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/regmap/regcache-flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6e4f287

Please sign in to comment.