Commit d66c9920 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jens Axboe
Browse files

bcache: Fix an error code in bch_dump_read()



The copy_to_user() function returns the number of bytes remaining to be
copied, but the intention here was to return -EFAULT if the copy fails.

Fixes: cafe5635 ("bcache: A block layer cache")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarColy Li <colyli@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d55a4ae9
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -178,10 +178,9 @@ static ssize_t bch_dump_read(struct file *file, char __user *buf,
	while (size) {
		struct keybuf_key *w;
		unsigned int bytes = min(i->bytes, size);
		int err = copy_to_user(buf, i->buf, bytes);

		if (err)
			return err;
		if (copy_to_user(buf, i->buf, bytes))
			return -EFAULT;

		ret	 += bytes;
		buf	 += bytes;