Some fields will be introduced in the regmap structure that should be set to 0 by default. So, once we allocate a regmap, make sure it is zeroed out to avoid unexpected defaults for those values.
Signed-off-by: Pratyush Yadav <[email protected]> --- drivers/core/regmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 74225361fd..24651fb3ec 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -30,10 +30,12 @@ DECLARE_GLOBAL_DATA_PTR; static struct regmap *regmap_alloc(int count) { struct regmap *map; + size_t size = sizeof(*map) + sizeof(map->ranges[0]) * count; - map = malloc(sizeof(*map) + sizeof(map->ranges[0]) * count); + map = malloc(size); if (!map) return NULL; + memset(map, 0, size); map->range_count = count; return map; -- 2.26.2

