From owner-svn-src-all@FreeBSD.ORG Sat Nov 27 00:26:08 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7A631065672; Sat, 27 Nov 2010 00:26:08 +0000 (UTC) (envelope-from mjacob@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A53F38FC0A; Sat, 27 Nov 2010 00:26:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAR0Q814000774; Sat, 27 Nov 2010 00:26:08 GMT (envelope-from mjacob@svn.freebsd.org) Received: (from mjacob@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAR0Q81o000771; Sat, 27 Nov 2010 00:26:08 GMT (envelope-from mjacob@svn.freebsd.org) Message-Id: <201011270026.oAR0Q81o000771@svn.freebsd.org> From: Matt Jacob Date: Sat, 27 Nov 2010 00:26:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215917 - stable/8/sbin/geom/class/multipath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Nov 2010 00:26:08 -0000 Author: mjacob Date: Sat Nov 27 00:26:08 2010 New Revision: 215917 URL: http://svn.freebsd.org/changeset/base/215917 Log: This is an MFC of 211282 Avoid a memory leak. Modified: stable/8/sbin/geom/class/multipath/geom_multipath.c Directory Properties: stable/8/sbin/geom/class/multipath/ (props changed) Modified: stable/8/sbin/geom/class/multipath/geom_multipath.c ============================================================================== --- stable/8/sbin/geom/class/multipath/geom_multipath.c Sat Nov 27 00:23:55 2010 (r215916) +++ stable/8/sbin/geom/class/multipath/geom_multipath.c Sat Nov 27 00:26:08 2010 (r215917) @@ -149,16 +149,6 @@ mp_label(struct gctl_req *req) } /* - * Allocate a sector to write as metadata. - */ - sector = malloc(secsize); - if (sector == NULL) { - gctl_error(req, "unable to allocate metadata buffer"); - return; - } - memset(sector, 0, secsize); - - /* * Generate metadata. */ strlcpy(md.md_magic, G_MULTIPATH_MAGIC, sizeof(md.md_magic)); @@ -191,6 +181,16 @@ mp_label(struct gctl_req *req) } /* + * Allocate a sector to write as metadata. + */ + sector = malloc(secsize); + if (sector == NULL) { + gctl_error(req, "unable to allocate metadata buffer"); + return; + } + memset(sector, 0, secsize); + + /* * encode the metadata */ multipath_metadata_encode(&md, sector);