Date: Thu, 17 Dec 2015 06:35:32 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r292396 - stable/9/sbin/geom/class/multipath Message-ID: <201512170635.tBH6ZWKW041674@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Thu Dec 17 06:35:31 2015 New Revision: 292396 URL: https://svnweb.freebsd.org/changeset/base/292396 Log: MFstable/10 r292395: MFC r292048: Don't leak rsector/sector in mp_label(..) Use calloc instead of malloc + memset(.., 0, ..) when allocating sector Differential Revision: https://reviews.freebsd.org/D4450 Reported by: cppcheck Reviewed by: mav Sponsored by: EMC / Isilon Storage Division Modified: stable/9/sbin/geom/class/multipath/geom_multipath.c Directory Properties: stable/9/ (props changed) stable/9/sbin/ (props changed) stable/9/sbin/geom/ (props changed) stable/9/sbin/geom/class/multipath/ (props changed) Modified: stable/9/sbin/geom/class/multipath/geom_multipath.c ============================================================================== --- stable/9/sbin/geom/class/multipath/geom_multipath.c Thu Dec 17 06:31:55 2015 (r292395) +++ stable/9/sbin/geom/class/multipath/geom_multipath.c Thu Dec 17 06:35:31 2015 (r292396) @@ -220,17 +220,15 @@ mp_label(struct gctl_req *req) /* * 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; } /* @@ -245,7 +243,7 @@ mp_label(struct gctl_req *req) 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; } /* @@ -273,6 +271,9 @@ mp_label(struct gctl_req *req) name2, name); } } +done: + free(rsector); + free(sector); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512170635.tBH6ZWKW041674>