Skip to content

Commit d14d2b7

Browse files
stefanhaRHdavem330
authored andcommitted
vhost: fix vhost_vq_access_ok() log check
Commit d65026c ("vhost: validate log when IOTLB is enabled") introduced a regression. The logic was originally: if (vq->iotlb) return 1; return A && B; After the patch the short-circuit logic for A was inverted: if (A || vq->iotlb) return A; return B; This patch fixes the regression by rewriting the checks in the obvious way, no longer returning A when vq->iotlb is non-NULL (which is hard to understand). Reported-by: [email protected] Cc: Jason Wang <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7ced6c9 commit d14d2b7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/vhost/vhost.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,12 @@ static int vq_log_access_ok(struct vhost_virtqueue *vq,
12441244
/* Caller should have vq mutex and device mutex */
12451245
int vhost_vq_access_ok(struct vhost_virtqueue *vq)
12461246
{
1247-
int ret = vq_log_access_ok(vq, vq->log_base);
1247+
if (!vq_log_access_ok(vq, vq->log_base))
1248+
return 0;
12481249

1249-
if (ret || vq->iotlb)
1250-
return ret;
1250+
/* Access validation occurs at prefetch time with IOTLB */
1251+
if (vq->iotlb)
1252+
return 1;
12511253

12521254
return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used);
12531255
}

0 commit comments

Comments
 (0)