From: Jan Beulich Date: Tue, 23 Mar 2021 16:01:30 +0000 (+0100) Subject: VT-d: correct off-by-1 in number-of-IOMMUs check X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~806 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b9b3082002cac68726fb303e0abd2ff0113d4657;p=xen.git VT-d: correct off-by-1 in number-of-IOMMUs check Otherwise, if we really run on a system with this many IOMMUs, entering/leaving S3 would overrun iommu_state[]. Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian Release-Acked-by: Ian Jackson --- diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 9b58d566c8..44e407d19f 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1168,10 +1168,10 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd) unsigned long sagaw, nr_dom; int agaw; - if ( nr_iommus > MAX_IOMMUS ) + if ( nr_iommus >= MAX_IOMMUS ) { dprintk(XENLOG_ERR VTDPREFIX, - "IOMMU: nr_iommus %d > MAX_IOMMUS\n", nr_iommus); + "IOMMU: nr_iommus %d > MAX_IOMMUS\n", nr_iommus + 1); return -ENOMEM; }