From mboxrd@z Thu Jan 1 00:00:00 1970
From: Pratyush Yadav
Date: Sat, 6 Jun 2020 02:00:19 +0530
Subject: [PATCH v2 2/8] regmap: zero out the regmap on allocation
In-Reply-To: <20200605203025.15466-1-p.yadav@ti.com>
References: <20200605203025.15466-1-p.yadav@ti.com>
Message-ID: <20200605203025.15466-3-p.yadav@ti.com>
List-Id:
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
To: u-boot@lists.denx.de
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
---
drivers/core/regmap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 74225361fd..809f58489f 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;
--
2.27.0