Skip to content

Commit

Permalink
bcache: Fix an error code in bch_dump_read()
Browse files Browse the repository at this point in the history
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: cafe563 ("bcache: A block layer cache")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Dan Carpenter authored and Jens Axboe committed Sep 3, 2019
1 parent d55a4ae commit d66c992
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/md/bcache/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d66c992

Please sign in to comment.