diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c index 66a6b8291..f4f5f420f 100644 --- a/daemons/lvmetad/lvmetad-core.c +++ b/daemons/lvmetad/lvmetad-core.c @@ -2528,10 +2528,8 @@ inval: info = dm_hash_lookup(s->vgid_to_info, uuid); if (!info) { - info = malloc(sizeof(struct vg_info)); - if (!info) + if (!(info = dm_zalloc(sizeof(struct vg_info)))) goto bad; - memset(info, 0, sizeof(struct vg_info)); if (!dm_hash_insert(s->vgid_to_info, uuid, (void*)info)) goto bad; } diff --git a/libdm/datastruct/hash.c b/libdm/datastruct/hash.c index 6df3efe61..fb153cefa 100644 --- a/libdm/datastruct/hash.c +++ b/libdm/datastruct/hash.c @@ -102,11 +102,9 @@ struct dm_hash_table *dm_hash_create(unsigned size_hint) hc->num_slots = new_size; len = sizeof(*(hc->slots)) * new_size; - if (!(hc->slots = dm_malloc(len))) { - stack; - goto bad; - } - memset(hc->slots, 0, len); + if (!(hc->slots = dm_zalloc(len))) + goto_bad; + return hc; bad: diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 8bee24be0..3965be6a2 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -1156,11 +1156,9 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count) while (repeat_count--) len *= 2; - if (!(dmi = dm_malloc(len))) + if (!(dmi = dm_zalloc(len))) return NULL; - memset(dmi, 0, len); - version = &_cmd_data_v4[dmt->type].version; dmi->version[0] = (*version)[0];