diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2018-10-24 14:05:34 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-10-24 15:21:57 +0000 |
commit | 3d3b9550dbee81d3cca85c593015edf2ac3191c2 (patch) | |
tree | 8166025a1a904ccae62872183f659fc30121087e /src | |
parent | 71615399e194847d7833b744caedab9b841733e5 (diff) |
vlib: Fix pci io bar read/write fd leak
Few devices provide PCI bar region(s) through I/O.
If any such device driver opens I/O "fd" to read and write,
needs to close it, when pci device is going to be deleted.
Change-Id: Iba104e56f76c6bf9ccd27bf2223bad39b1301763
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vlib/linux/pci.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c index 724bb9d3a4a..c6fa8a7da34 100644 --- a/src/vlib/linux/pci.c +++ b/src/vlib/linux/pci.c @@ -1210,6 +1210,10 @@ 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; + /* + * pci io bar read/write fd + */ + p->io_fd = -1; pci_log_debug (vm, p, "open vid:0x%04x did:0x%04x driver:%s iommu_group:%d", di->vendor_id, di->device_id, di->driver_name, @@ -1253,6 +1257,8 @@ vlib_pci_device_close (vlib_main_t * vm, vlib_pci_dev_handle_t h) irq = &p->intx_irq; clib_file_del_by_index (&file_main, irq->clib_file_index); close (p->config_fd); + if (p->io_fd != -1) + close (p->io_fd); } else if (p->type == LINUX_PCI_DEVICE_TYPE_VFIO) { |