From: Pratyush Yadav Date: Thu, 24 Sep 2020 04:34:11 +0000 (+0530) Subject: regmap: zero out the regmap on allocation X-Git-Tag: v2021.10~497^2~7^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97d8a6970a3da5856633f2a705f0687fca4af9a5;p=platform%2Fkernel%2Fu-boot.git regmap: zero out the regmap on allocation 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 Reviewed-by: Simon Glass --- diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 7422536..809f584 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -30,8 +30,9 @@ 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 = calloc(1, size); if (!map) return NULL; map->range_count = count;