net/nfp: fix file descriptor check
authorAlejandro Lucero <alejandro.lucero@netronome.com>
Mon, 8 Apr 2019 09:20:40 +0000 (10:20 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 12 Apr 2019 09:02:02 +0000 (11:02 +0200)
Although it is rather unlikely getting 0 as the descriptor handle, better
to contemplate that possibility.

Coverity issue: 195018
Fixes: 896c265ef954 ("net/nfp: use new CPP interface")
Cc: stable@dpdk.org
Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
drivers/net/nfp/nfp_net.c

index 3e6178c..50058e0 100644 (file)
@@ -3491,7 +3491,7 @@ nfp_fw_upload(struct rte_pci_device *dev, struct nfp_nsp *nsp, char *card)
 
        PMD_DRV_LOG(DEBUG, "Trying with fw file: %s", fw_name);
        fw_f = open(fw_name, O_RDONLY);
-       if (fw_f > 0)
+       if (fw_f >= 0)
                goto read_fw;
 
        /* Then try the PCI name */
@@ -3500,7 +3500,7 @@ nfp_fw_upload(struct rte_pci_device *dev, struct nfp_nsp *nsp, char *card)
 
        PMD_DRV_LOG(DEBUG, "Trying with fw file: %s", fw_name);
        fw_f = open(fw_name, O_RDONLY);
-       if (fw_f > 0)
+       if (fw_f >= 0)
                goto read_fw;
 
        /* Finally try the card type and media */