summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsuya Mukawa <mukawa@igel.co.jp>2013-09-04 03:34:35 -0400
committerThomas Monjalon <thomas.monjalon@6wind.com>2013-09-12 17:16:43 +0200
commit165c66a48d3be0304ef8116143581a96c93258c7 (patch)
treee4f6ade151688b500b0fb33efdc38c8845f8a402
parente1d222e977af89bdc070260de5ef402b948771e1 (diff)
downloaddpdk-165c66a48d3be0304ef8116143581a96c93258c7.zip
dpdk-165c66a48d3be0304ef8116143581a96c93258c7.tar.gz
dpdk-165c66a48d3be0304ef8116143581a96c93258c7.tar.xz
pci: fix closing an unopened file descriptor
If CONFIG_RTE_EAL_UNBIND_PORTS is set and a non Intel PMD is used, an unopened file descriptor will be illegally closed in the finalized phase of EAL. The fix adds a correct initial value to the file descriptor, and check it before closing it. Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
-rw-r--r--lib/librte_eal/linuxapp/eal/eal_pci.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index c793148..31e4efa 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -514,6 +514,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
}
memset(dev, 0, sizeof(*dev));
+ dev->intr_handle.fd = -1;
dev->addr.domain = domain;
dev->addr.bus = bus;
dev->addr.devid = devid;
@@ -718,7 +719,7 @@ pci_exit_process(struct rte_pci_device *dev)
RTE_LOG(ERR, EAL, "Error with munmap\n");
return -1;
}
- if (close(dev->intr_handle.fd) == -1){
+ if ((dev->intr_handle.fd != -1) && (close(dev->intr_handle.fd) == -1)) {
RTE_LOG(ERR, EAL, "Error closing interrupt handle\n");
return -1;
}