From: Yunjian Wang Date: Mon, 6 Jul 2020 12:27:32 +0000 (+0800) Subject: net/af_packet: fix check of file descriptors X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c6d1a552a8798df02bf85627c5d47a28ccdc62f8;p=dpdk.git net/af_packet: fix check of file descriptors Zero is a valid fd. It will fail to check the fd if the fd is zero. Fixes: 527740ccfaec ("af_packet: fix some leaks") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index e1e7f3973b..db5de8e45e 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -645,6 +645,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, for (q = 0; q < nb_queues; q++) { (*internals)->rx_queue[q].map = MAP_FAILED; (*internals)->tx_queue[q].map = MAP_FAILED; + (*internals)->rx_queue[q].sockfd = -1; + (*internals)->tx_queue[q].sockfd = -1; } req = &((*internals)->req); @@ -848,7 +850,7 @@ error: rte_free((*internals)->rx_queue[q].rd); rte_free((*internals)->tx_queue[q].rd); - if (((*internals)->rx_queue[q].sockfd != 0) && + if (((*internals)->rx_queue[q].sockfd >= 0) && ((*internals)->rx_queue[q].sockfd != qsockfd)) close((*internals)->rx_queue[q].sockfd); }