summaryrefslogtreecommitdiff
path: root/fs/9p
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2026-01-15 13:23:40 +0100
committerChristian Brauner <brauner@kernel.org>2026-01-16 10:51:12 +0100
commit6cbfdf89470ef3c2110f376a507d135e7a7a7378 (patch)
tree6991f78aff4f603c9b186e0e4a4fe031d5828861 /fs/9p
parent88ec797c468097a8ce97694ed11ea9c982598ec0 (diff)
posix_acl: make posix_acl_to_xattr() alloc the buffer
Without exception all caller do that. So move the allocation into the helper. This reduces boilerplate and removes unnecessary error checking. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Link: https://patch.msgid.link/20260115122341.556026-1-mszeredi@redhat.com Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/acl.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index 633da5e37299..ae7e7cf7523a 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -167,17 +167,11 @@ int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
if (retval)
goto err_out;
- size = posix_acl_xattr_size(acl->a_count);
-
- value = kzalloc(size, GFP_NOFS);
+ value = posix_acl_to_xattr(&init_user_ns, acl, &size, GFP_NOFS);
if (!value) {
retval = -ENOMEM;
goto err_out;
}
-
- retval = posix_acl_to_xattr(&init_user_ns, acl, value, size);
- if (retval < 0)
- goto err_out;
}
/*
@@ -257,13 +251,10 @@ static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl)
return 0;
/* Set a setxattr request to server */
- size = posix_acl_xattr_size(acl->a_count);
- buffer = kmalloc(size, GFP_KERNEL);
+ buffer = posix_acl_to_xattr(&init_user_ns, acl, &size, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
- retval = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
- if (retval < 0)
- goto err_free_out;
+
switch (type) {
case ACL_TYPE_ACCESS:
name = XATTR_NAME_POSIX_ACL_ACCESS;
@@ -275,7 +266,6 @@ static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl)
BUG();
}
retval = v9fs_fid_xattr_set(fid, name, buffer, size, 0);
-err_free_out:
kfree(buffer);
return retval;
}