svn commit: r319077 - head/sys/fs/ext2fs

Pedro F. Giffuni pfg at FreeBSD.org
Sun May 28 17:48:55 UTC 2017


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
+}


More information about the svn-src-all mailing list