[PATCH] bcachefs: debug: Fix copy_to_user() error code in flush_buf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The copy_to_user() function returns the number of bytes remaining to
be copied but we want to return -EFAULT to the user.

Fixes: e0750d947352 ("bcachefs: Initial commit")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
 fs/bcachefs/debug.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c
index 404148bd348a..e65c0ab0c9ad 100644
--- a/fs/bcachefs/debug.c
+++ b/fs/bcachefs/debug.c
@@ -319,10 +319,9 @@ static ssize_t flush_buf(struct dump_iter *i)
 {
 	if (i->buf.pos) {
 		size_t bytes = min_t(size_t, i->buf.pos, i->size);
-		int err = copy_to_user(i->ubuf, i->buf.buf, bytes);
 
-		if (err)
-			return err;
+		if (copy_to_user(i->ubuf, i->buf.buf, bytes))
+			return -EFAULT;
 
 		i->ret	 += bytes;
 		i->ubuf	 += bytes;
-- 
2.39.2




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux