From: Bruce Richardson Date: Tue, 16 Dec 2014 16:30:22 +0000 (+0000) Subject: af_packet: fix crash on initialization failure X-Git-Tag: spdx-start~9933 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b5af5c7967150fc541dba541c1ad8dc8aa642bff;p=dpdk.git af_packet: fix crash on initialization failure The cleanup code on error checks for *internals being NULL only after using the pointer to perform other cleanup. Fix this by moving the clean-up based on the pointer inside the check for NULL. Signed-off-by: Bruce Richardson --- diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c index d0fb3eb32e..ad7242cd6d 100644 --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c @@ -676,14 +676,15 @@ error: rte_free(data); if (pci_dev) rte_free(pci_dev); - for (q = 0; q < nb_queues; q++) { - if ((*internals)->rx_queue[q].rd) - rte_free((*internals)->rx_queue[q].rd); - if ((*internals)->tx_queue[q].rd) - rte_free((*internals)->tx_queue[q].rd); - } - if (*internals) + if (*internals) { + for (q = 0; q < nb_queues; q++) { + if ((*internals)->rx_queue[q].rd) + rte_free((*internals)->rx_queue[q].rd); + if ((*internals)->tx_queue[q].rd) + rte_free((*internals)->tx_queue[q].rd); + } rte_free(*internals); + } return -1; }