From owner-svn-src-head@freebsd.org Sun May 28 17:48:55 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2B17D85E0D; Sun, 28 May 2017 17:48:55 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9734D1215; Sun, 28 May 2017 17:48:55 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4SHmsJT016676; Sun, 28 May 2017 17:48:54 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4SHmsaU016675; Sun, 28 May 2017 17:48:54 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201705281748.v4SHmsaU016675@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 28 May 2017 17:48:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319077 - head/sys/fs/ext2fs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 May 2017 17:48:55 -0000 Author: pfg Date: Sun May 28 17:48:54 2017 New Revision: 319077 URL: https://svnweb.freebsd.org/changeset/base/319077 Log: Fix potential memory leak. Moving the allocation forward, just before it's actually needed, seems sensible. Add newline character at the last line while here. Reported by: pluknet Differential Revision: https://reviews.freebsd.org/D10974 Modified: head/sys/fs/ext2fs/ext2_acl.c Modified: head/sys/fs/ext2fs/ext2_acl.c ============================================================================== --- head/sys/fs/ext2fs/ext2_acl.c Sun May 28 17:25:47 2017 (r319076) +++ head/sys/fs/ext2fs/ext2_acl.c Sun May 28 17:48:54 2017 (r319077) @@ -210,11 +210,6 @@ ext2_getacl_posix1e(struct vop_getacl_ar int len; int error; - len = sizeof(*ap->a_aclp) + sizeof(struct ext2_acl_header); - value = malloc(len, M_ACL, M_WAITOK); - if (!value) - return (ENOMEM); - switch (ap->a_type) { case ACL_TYPE_DEFAULT: attrnamespace = POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE; @@ -228,6 +223,11 @@ ext2_getacl_posix1e(struct vop_getacl_ar return (EINVAL); } + len = sizeof(*ap->a_aclp) + sizeof(struct ext2_acl_header); + value = malloc(len, M_ACL, M_WAITOK); + if (!value) + return (ENOMEM); + error = vn_extattr_get(ap->a_vp, IO_NODELOCKED, attrnamespace, attrname, &len, value, ap->a_td); switch (error) { @@ -518,4 +518,4 @@ ext2_aclcheck(struct vop_aclcheck_args * } return (acl_posix1e_check(ap->a_aclp)); -} \ No newline at end of file +}