From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 862DC7EB0 for ; Tue, 16 Dec 2014 17:50:55 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 16 Dec 2014 08:30:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,587,1413270000"; d="scan'208";a="648551507" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 16 Dec 2014 08:30:26 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id sBGGUOAs008784; Tue, 16 Dec 2014 16:30:25 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id sBGGUOtT022298; Tue, 16 Dec 2014 16:30:24 GMT Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id sBGGUOUQ022294; Tue, 16 Dec 2014 16:30:24 GMT From: Bruce Richardson To: dev@dpdk.org Date: Tue, 16 Dec 2014 16:30:22 +0000 Message-Id: <1418747424-22254-2-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1418747424-22254-1-git-send-email-bruce.richardson@intel.com> References: <1418747424-22254-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 1/3] af_packet: ensure *internals is not null when dereferencing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2014 16:50:57 -0000 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 --- lib/librte_pmd_af_packet/rte_eth_af_packet.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 d0fb3eb..ad7242c 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; } -- 1.9.3