From: Qi Zhang Date: Thu, 12 Jul 2018 14:01:42 +0000 (+0800) Subject: vfio: fix PCI address comparison X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2a3de3710fbc54499867b44951b5b41cdb2aba35;p=dpdk.git vfio: fix PCI address comparison When use memcmp to compare two PCI address, sizeof(struct rte_pci_addr) is 4 bytes aligned, and it is 8. While only 7 byte of struct rte_pci_addr is valid. So compare the 8th byte will cause the unexpected result, which happens when repeatedly attach/detach a device. Fixes: 94c0776b1bad ("vfio: support hotplug") Cc: stable@dpdk.org Signed-off-by: Qi Zhang Acked-by: Gaetan Rivet --- diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index aeeaa9ed88..933b95540a 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -642,7 +642,7 @@ pci_vfio_unmap_resource(struct rte_pci_device *dev) vfio_res_list = RTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list); /* Get vfio_res */ TAILQ_FOREACH(vfio_res, vfio_res_list, next) { - if (memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr))) + if (rte_pci_addr_cmp(&vfio_res->pci_addr, &dev->addr)) continue; break; }