Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 May 2017 17:48:54 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319077 - head/sys/fs/ext2fs
Message-ID:  <201705281748.v4SHmsaU016675@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705281748.v4SHmsaU016675>