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.
@@ -1236,6 +1236,7 @@ vlib_pci_device_open (vlib_main_t * vm, vlib_pci_addr_t * addr,
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,6 +1283,7 @@ vlib_pci_device_close (vlib_main_t * vm, vlib_pci_dev_handle_t h)
if (p->type == LINUX_PCI_DEVICE_TYPE_UIO)
{
irq = &p->intx_irq;
+ 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)
@@ -1296,6 +1298,7 @@ vlib_pci_device_close (vlib_main_t * vm, vlib_pci_dev_handle_t h)
err = vfio_set_irqs (vm, p, VFIO_PCI_INTX_IRQ_INDEX, 0, 0,
VFIO_IRQ_SET_ACTION_TRIGGER, 0);
clib_error_free (err);
+ if (irq->clib_file_index != -1)
clib_file_del_by_index (&file_main, irq->clib_file_index);
close (irq->fd);
}
