From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id BE9F35A26 for ; Wed, 5 Aug 2015 14:36:49 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 05 Aug 2015 05:36:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,616,1432623600"; d="scan'208";a="619742264" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 05 Aug 2015 05:36:47 -0700 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 t75CakZP011771; Wed, 5 Aug 2015 13:36:46 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t75Cakwp009007; Wed, 5 Aug 2015 13:36:46 +0100 Received: (from bairemon@localhost) by sivswdev01.ir.intel.com with id t75CakA8009003; Wed, 5 Aug 2015 13:36:46 +0100 From: Bernard Iremonger To: dev@dpdk.org Date: Wed, 5 Aug 2015 13:36:44 +0100 Message-Id: <1438778204-8896-1-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create() 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: Wed, 05 Aug 2015 12:36:50 -0000 if the name parameter to rte_eth_bond_create() was NULL, there was a segmentation fault because eth_dev was also NULL. Signed-off-by: Bernard Iremonger --- drivers/net/bonding/rte_eth_bond_api.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 4ca26dd..0681d1a 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -239,6 +239,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0, socket_id); + if (eth_dev->data->mac_addrs == NULL) { + RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs"); + goto err; + } eth_dev->data->dev_started = 0; eth_dev->data->promiscuous = 0; @@ -285,8 +289,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) err: rte_free(pci_dev); rte_free(internals); - rte_free(eth_dev->data->mac_addrs); - + if (eth_dev != NULL) { + rte_free(eth_dev->data->mac_addrs); + rte_eth_dev_release_port(eth_dev); + } return -1; } -- 1.9.1