summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2019-09-03 16:25:44 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-01-27 16:51:09 +0300
commite7728e18a728bcbd072bca82650b10e0ba55a238 (patch)
treeb4c3515708f3bedd49cbde8ba3d16ac9fe120e5e /drivers/md
parent2404a2e35aaf74add564abfdb09273bbffae8ace (diff)
downloadlinux-e7728e18a728bcbd072bca82650b10e0ba55a238.tar.xz
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 <dan.carpenter@oracle.com> Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bcache/debug.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 8c53d874ada4..f6b60d5908f7 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;