aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2017-05-28 17:48:54 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2017-05-28 17:48:54 +0000
commit03222757517395fd7174b8db4e0b5304361eea0f (patch)
treee017955e40e7525312616ada1dc633b933a916ed
parentf2e34224fa43778587b0e0351c5de373404cb650 (diff)
downloadsrc-03222757517395fd7174b8db4e0b5304361eea0f.tar.gz
src-03222757517395fd7174b8db4e0b5304361eea0f.zip
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
Notes
Notes: svn path=/head/; revision=319077
-rw-r--r--sys/fs/ext2fs/ext2_acl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/fs/ext2fs/ext2_acl.c b/sys/fs/ext2fs/ext2_acl.c
index 2a20d7359159..7ac1707cb543 100644
--- a/sys/fs/ext2fs/ext2_acl.c
+++ b/sys/fs/ext2fs/ext2_acl.c
@@ -210,11 +210,6 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap)
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_args *ap)
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 *ap)
}
return (acl_posix1e_check(ap->a_aclp));
-} \ No newline at end of file
+}