pci: Fix the crash on deleting the pci device
clib_file_index is 0 if it is not initialized result in
following assertion on deleteing the pci device.
vpp/src/vppinfra/file.h:122 (clib_file_del_by_index) assertion `! pool_is_free (um->file_pool, _e)' fails
This patch fixes the issue by initializing the clib_file_index to -1.
Change-Id: I51d23f18e7ccf3143a4765d05aafc1363a007737
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c
index ec35adb..8b614c7 100644
--- a/src/vlib/linux/pci.c
+++ b/src/vlib/linux/pci.c
@@ -1236,6 +1236,7 @@
p->handle = p - lpm->linux_pci_devices;
p->addr.as_u32 = di->addr.as_u32;
p->intx_irq.fd = -1;
+ p->intx_irq.clib_file_index = -1;
p->numa_node = di->numa_node;
/*
* pci io bar read/write fd
@@ -1282,7 +1283,8 @@
if (p->type == LINUX_PCI_DEVICE_TYPE_UIO)
{
irq = &p->intx_irq;
- clib_file_del_by_index (&file_main, irq->clib_file_index);
+ if (irq->clib_file_index != -1)
+ clib_file_del_by_index (&file_main, irq->clib_file_index);
close (p->config_fd);
if (p->io_fd != -1)
close (p->io_fd);
@@ -1296,7 +1298,8 @@
err = vfio_set_irqs (vm, p, VFIO_PCI_INTX_IRQ_INDEX, 0, 0,
VFIO_IRQ_SET_ACTION_TRIGGER, 0);
clib_error_free (err);
- clib_file_del_by_index (&file_main, irq->clib_file_index);
+ if (irq->clib_file_index != -1)
+ clib_file_del_by_index (&file_main, irq->clib_file_index);
close (irq->fd);
}