aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2019-04-02 11:09:49 +0000
committerDamjan Marion <dmarion@me.com>2019-04-03 14:42:37 +0000
commit692f9b1205be8e61c0782b0711ec2393f8203e3e (patch)
tree16b0bfe32a202cbdae51302f36859389ef6350eb /src
parent211ef2eb24752faeb8a8cb1e3e727e008acf921e (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/linux/pci.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c
index ec35adb1c37..8b614c751a1 100644
--- a/src/vlib/linux/pci.c
+++ b/src/vlib/linux/pci.c
@@ -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,7 +1283,8 @@ 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;
- 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 @@ 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);
- 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);
}