summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_ioctl32.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-02-27 02:30:40 +0100
committerDarrick J. Wong <darrick.wong@oracle.com>2020-03-03 05:55:54 +0100
commiteb241c747463666c34b8f578b8dd7aa5d1fc0273 (patch)
tree9c5f04962adb5fd65c27ec0bc37d85e2e3729c1b /fs/xfs/xfs_ioctl32.c
parentxfs: lift common checks into xfs_ioc_attr_list (diff)
downloadlinux-eb241c747463666c34b8f578b8dd7aa5d1fc0273.tar.xz
linux-eb241c747463666c34b8f578b8dd7aa5d1fc0273.zip
xfs: lift buffer allocation into xfs_ioc_attr_list
Lift the buffer allocation from the two callers into xfs_ioc_attr_list. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_ioctl32.c')
-rw-r--r--fs/xfs/xfs_ioctl32.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 840d17951407..17e14916757b 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -359,7 +359,6 @@ xfs_compat_attrlist_by_handle(
compat_xfs_fsop_attrlist_handlereq_t __user *p = arg;
compat_xfs_fsop_attrlist_handlereq_t al_hreq;
struct dentry *dentry;
- char *kbuf;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -371,27 +370,16 @@ xfs_compat_attrlist_by_handle(
if (IS_ERR(dentry))
return PTR_ERR(dentry);
- error = -ENOMEM;
- kbuf = kmem_zalloc_large(al_hreq.buflen, 0);
- if (!kbuf)
- goto out_dput;
-
cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
- error = xfs_ioc_attr_list(XFS_I(d_inode(dentry)), kbuf, al_hreq.buflen,
- al_hreq.flags, cursor);
+ error = xfs_ioc_attr_list(XFS_I(d_inode(dentry)),
+ compat_ptr(al_hreq.buffer), al_hreq.buflen,
+ al_hreq.flags, cursor);
if (error)
- goto out_kfree;
-
- if (copy_to_user(&p->pos, cursor, sizeof(attrlist_cursor_kern_t))) {
- error = -EFAULT;
- goto out_kfree;
- }
+ goto out_dput;
- if (copy_to_user(compat_ptr(al_hreq.buffer), kbuf, al_hreq.buflen))
+ if (copy_to_user(&p->pos, cursor, sizeof(attrlist_cursor_kern_t)))
error = -EFAULT;
-out_kfree:
- kmem_free(kbuf);
out_dput:
dput(dentry);
return error;