Skip to content

Commit 816db76

Browse files
jasowangdavem330
authored andcommitted
vhost: correctly check the return value of translate_desc() in log_used()
When fail, translate_desc() returns negative value, otherwise the number of iovs. So we should fail when the return value is negative instead of a blindly check against zero. Detected by CoverityScan, CID# 1442593: Control flow issues (DEADCODE) Fixes: cc5e710 ("vhost: log dirty page correctly") Acked-by: Michael S. Tsirkin <mst@redhat.com> Reported-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5cd856a commit 816db76

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/vhost/vhost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ static int log_used(struct vhost_virtqueue *vq, u64 used_offset, u64 len)
17881788

17891789
ret = translate_desc(vq, (uintptr_t)vq->used + used_offset,
17901790
len, iov, 64, VHOST_ACCESS_WO);
1791-
if (ret)
1791+
if (ret < 0)
17921792
return ret;
17931793

17941794
for (i = 0; i < ret; i++) {

0 commit comments

Comments
 (0)