]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.20/vhost-correctly-check-the-return-value-of-translate_.patch
patches for 4.20
[thirdparty/kernel/stable-queue.git] / queue-4.20 / vhost-correctly-check-the-return-value-of-translate_.patch
1 From 3e7aa46811cd9f98621d6c9d46bda275d52eb12d Mon Sep 17 00:00:00 2001
2 From: Jason Wang <jasowang@redhat.com>
3 Date: Tue, 19 Feb 2019 14:53:44 +0800
4 Subject: vhost: correctly check the return value of translate_desc() in
5 log_used()
6
7 [ Upstream commit 816db7663565cd23f74ed3d5c9240522e3fb0dda ]
8
9 When fail, translate_desc() returns negative value, otherwise the
10 number of iovs. So we should fail when the return value is negative
11 instead of a blindly check against zero.
12
13 Detected by CoverityScan, CID# 1442593: Control flow issues (DEADCODE)
14
15 Fixes: cc5e71075947 ("vhost: log dirty page correctly")
16 Acked-by: Michael S. Tsirkin <mst@redhat.com>
17 Reported-by: Stephen Hemminger <stephen@networkplumber.org>
18 Signed-off-by: Jason Wang <jasowang@redhat.com>
19 Signed-off-by: David S. Miller <davem@davemloft.net>
20 Signed-off-by: Sasha Levin <sashal@kernel.org>
21 ---
22 drivers/vhost/vhost.c | 2 +-
23 1 file changed, 1 insertion(+), 1 deletion(-)
24
25 diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
26 index cf82e72663976..5eaeca805c95c 100644
27 --- a/drivers/vhost/vhost.c
28 +++ b/drivers/vhost/vhost.c
29 @@ -1784,7 +1784,7 @@ static int log_used(struct vhost_virtqueue *vq, u64 used_offset, u64 len)
30
31 ret = translate_desc(vq, (uintptr_t)vq->used + used_offset,
32 len, iov, 64, VHOST_ACCESS_WO);
33 - if (ret)
34 + if (ret < 0)
35 return ret;
36
37 for (i = 0; i < ret; i++) {
38 --
39 2.19.1
40