net/tap: fix file descriptor check
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 6 Nov 2018 19:30:05 +0000 (11:30 -0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 14 Nov 2018 01:14:12 +0000 (02:14 +0100)
Static analysis tools don't like the fact that fd could be zero
in the error path. This won't happen in real world because
stdin would have to be closed, then other error occurring.

Coverity issue: 14079
Fixes: 02f96a0a82d1 ("net/tap: add TUN/TAP device PMD")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Keith Wiles <keith.wiles@intel.com>
drivers/net/tap/rte_eth_tap.c

index e7817e8..75b82f2 100644 (file)
@@ -248,7 +248,7 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
        return fd;
 
 error:
-       if (fd > 0)
+       if (fd >= 0)
                close(fd);
        return -1;
 }