]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
Always initialise a struct super_type to zero
[thirdparty/mdadm.git] / super-ddf.c
index acfb491655ed7ab37b6fc12b162180fc3683f49b..0c2a0138c5b9b480ce84c9beda400cb2e7a8628a 100644 (file)
@@ -820,6 +820,7 @@ static struct supertype *match_metadata_desc_ddf(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_ddf;
        st->max_devs = 512;
        st->minor_version = 0;
@@ -837,6 +838,7 @@ static struct supertype *match_metadata_desc_ddf_bvd(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_ddf_bvd;
        st->max_devs = 512;
        st->minor_version = 0;
@@ -853,6 +855,7 @@ static struct supertype *match_metadata_desc_ddf_svd(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_ddf_svd;
        st->max_devs = 512;
        st->minor_version = 0;
@@ -3045,8 +3048,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
         * Create a metadata_update record to update the
         * phys_refnum and lba_offset values
         */
-       mu = malloc(sizeof(*mu) + ddf->conf_rec_len * 512);
-       mu->buf = (char*)(mu+1);
+       mu = malloc(sizeof(*mu));
+       mu->buf = malloc(ddf->conf_rec_len * 512);
        mu->space = malloc(sizeof(struct vcl));
        mu->len = ddf->conf_rec_len;
        mu->next = *updates;