From 692f9b1205be8e61c0782b0711ec2393f8203e3e Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Tue, 2 Apr 2019 11:09:49 +0000 Subject: 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 --- src/vlib/linux/pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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); } -- cgit 1.2.3-korg