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 <[email protected]>
---
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