From: Dan Carpenter Date: Tue, 3 Sep 2019 13:25:44 +0000 (+0800) Subject: bcache: Fix an error code in bch_dump_read() X-Git-Tag: v4.19.99~104 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7728e18a728bcbd072bca82650b10e0ba55a238;p=platform%2Fkernel%2Flinux-rpi.git bcache: Fix an error code in bch_dump_read() [ Upstream commit d66c9920c0cf984cf99cab5036fd5f3a1b7fba46 ] 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: cafe56359144 ("bcache: A block layer cache") Signed-off-by: Dan Carpenter Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8c53d87..f6b60d5 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -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;