Index: sbin/geom/class/multipath/geom_multipath.c =================================================================== --- sbin/geom/class/multipath/geom_multipath.c +++ sbin/geom/class/multipath/geom_multipath.c @@ -162,6 +162,9 @@ return; } + rsector = NULL; + sector = NULL; + /* * First, check each provider to make sure it's the same size. * This also gets us our size and sectorsize for the metadata. @@ -221,17 +224,15 @@ /* * Allocate a sector to write as metadata. */ - sector = malloc(secsize); + sector = calloc(1, secsize); if (sector == NULL) { gctl_error(req, "unable to allocate metadata buffer"); return; } - memset(sector, 0, secsize); rsector = malloc(secsize); if (rsector == NULL) { - free(sector); gctl_error(req, "unable to allocate metadata buffer"); - return; + goto done; } /* @@ -246,7 +247,7 @@ error = g_metadata_store(name, sector, secsize); if (error != 0) { gctl_error(req, "cannot store metadata on %s: %s.", name, strerror(error)); - return; + goto done; } /* @@ -274,6 +275,9 @@ name2, name); } } +done: + free(rsector); + free(sector); }