]> git.itanic.dy.fi Git - linux-stable/commitdiff
bcachefs: fs-ioctl: Fix copy_to_user() error code
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 15 Sep 2023 12:55:23 +0000 (15:55 +0300)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:14 +0000 (17:10 -0400)
The copy_to_user() function returns the number of bytes that it wasn't
able to copy but we want to return -EFAULT to the user.

Fixes: e0750d947352 ("bcachefs: Initial commit")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-ioctl.c

index 141bcced031e25d9043122c78542cc09cb8586ed..0679b2f79fd6fdca71b820bac339f4bb4ffe2b3a 100644 (file)
@@ -122,7 +122,10 @@ static int bch2_ioc_fsgetxattr(struct bch_inode_info *inode,
 
        fa.fsx_projid = inode->ei_qid.q[QTYP_PRJ];
 
-       return copy_to_user(arg, &fa, sizeof(fa));
+       if (copy_to_user(arg, &fa, sizeof(fa)))
+               return -EFAULT;
+
+       return 0;
 }
 
 static int fssetxattr_inode_update_fn(struct btree_trans *trans,