diff options
author | Pratyush Yadav <p.yadav@ti.com> | 2020-09-24 07:34:11 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-09-30 18:55:22 +0300 |
commit | 97d8a6970a3da5856633f2a705f0687fca4af9a5 (patch) | |
tree | b16afc997aa314bb56fa0487e32c0b4365e1ef55 /drivers | |
parent | ffb22f6b847d21b30831c91294ec21d6a5e80ed4 (diff) | |
download | u-boot-97d8a6970a3da5856633f2a705f0687fca4af9a5.tar.xz |
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 <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/core/regmap.c | 3 |
1 files changed, 2 insertions, 1 deletions
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; |