[dpdk-dev] eal/linux: fix fd check before close

Message ID 1486734797-24637-1-git-send-email-wang.yong19@zte.com.cn (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Yong Wang Feb. 10, 2017, 1:53 p.m. UTC
  The "dev->intr_handle.fd" is possibly a negative value while it is
passed as an argument to function "close". Fix the check to the fd.

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Feb. 10, 2017, 1:24 p.m. UTC | #1
2017-02-10 08:53, Yong Wang:
> The "dev->intr_handle.fd" is possibly a negative value while it is
> passed as an argument to function "close". Fix the check to the fd.
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>

pci: fix UIO interrupt file descriptor check before close

Fixes: 5a60a7ffc801 ("pci: introduce functions to alloc and free uio resource")

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index 3e4ffb5..20a4a66 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -230,7 +230,7 @@ 
 		close(dev->intr_handle.uio_cfg_fd);
 		dev->intr_handle.uio_cfg_fd = -1;
 	}
-	if (dev->intr_handle.fd) {
+	if (dev->intr_handle.fd >= 0) {
 		close(dev->intr_handle.fd);
 		dev->intr_handle.fd = -1;
 		dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;