From patchwork Thu Dec 18 09:45:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mrzyglod X-Patchwork-Id: 2094 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 500068002; Thu, 18 Dec 2014 15:10:14 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 618741F5 for ; Thu, 18 Dec 2014 15:10:05 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 18 Dec 2014 06:05:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,601,1413270000"; d="scan'208";a="656389419" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 18 Dec 2014 06:08:18 -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 sBI9j7JU001654; Thu, 18 Dec 2014 09:45:07 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id sBI9j7h7000994; Thu, 18 Dec 2014 09:45:07 GMT Received: (from dtmrzglx@localhost) by sivswdev01.ir.intel.com with id sBI9j7aM000990; Thu, 18 Dec 2014 09:45:07 GMT From: Daniel Mrzyglod To: dev@dpdk.org Date: Thu, 18 Dec 2014 09:45:05 +0000 Message-Id: <1418895905-915-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] af_packet: fix memory allocation check 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In rte_eth_af_packet.c we are we are missing NULL pointer checks after calls to alocate memory for queues. Add checking NULL pointer and error handling. Signed-off-by: Daniel Mrzyglod Acked-by: Neil Horman --- lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 ++++ 1 file changed, 4 insertions(+) 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 ad7242c..236749b 100644 --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c @@ -603,6 +603,8 @@ rte_pmd_init_internals(const char *name, rdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd)); rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node); + if (rx_queue->rd == NULL) + goto error; for (i = 0; i < req->tp_frame_nr; ++i) { rx_queue->rd[i].iov_base = rx_queue->map + (i * framesize); rx_queue->rd[i].iov_len = req->tp_frame_size; @@ -615,6 +617,8 @@ rte_pmd_init_internals(const char *name, tx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr; tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node); + if (tx_queue->rd == NULL) + goto error; for (i = 0; i < req->tp_frame_nr; ++i) { tx_queue->rd[i].iov_base = tx_queue->map + (i * framesize); tx_queue->rd[i].iov_len = req->tp_frame_size;