From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 4DB61590C for ; Wed, 5 Aug 2015 14:48:35 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 05 Aug 2015 05:48:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,616,1432623600"; d="scan'208";a="619747784" Received: from pgsmsx107.gar.corp.intel.com ([10.221.44.105]) by orsmga003.jf.intel.com with ESMTP; 05 Aug 2015 05:48:32 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by PGSMSX107.gar.corp.intel.com (10.221.44.105) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 5 Aug 2015 20:48:30 +0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.38]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.213]) with mapi id 14.03.0224.002; Wed, 5 Aug 2015 20:48:29 +0800 From: "Liu, Yong" To: "Iremonger, Bernard" , "dev@dpdk.org" Thread-Topic: [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create() Thread-Index: AQHQz3trzL+dXkAn3kKzT/QXhb27XJ39WvXg Date: Wed, 5 Aug 2015 12:48:28 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10EB5A50@SHSMSX103.ccr.corp.intel.com> References: <1438778204-8896-1-git-send-email-bernard.iremonger@intel.com> In-Reply-To: <1438778204-8896-1-git-send-email-bernard.iremonger@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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:48:37 -0000 Tested-by: Marvin Liu > -----Original Message----- > From: Iremonger, Bernard > Sent: Wednesday, August 05, 2015 8:37 PM > To: dev@dpdk.org > Cc: Jastrzebski, MichalX K; Liu, Yong; Iremonger, Bernard > Subject: [PATCH v2 1/1] bonding: fix error handling in > rte_eth_bond_create() >=20 > if the name parameter to rte_eth_bond_create() was NULL, > there was a segmentation fault because eth_dev was also NULL. >=20 > Signed-off-by: Bernard Iremonger > --- > drivers/net/bonding/rte_eth_bond_api.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) >=20 > 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) >=20 > eth_dev->data->mac_addrs =3D rte_zmalloc_socket(name, ETHER_ADDR_LEN, > 0, > socket_id); > + if (eth_dev->data->mac_addrs =3D=3D NULL) { > + RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs"); > + goto err; > + } >=20 > eth_dev->data->dev_started =3D 0; > eth_dev->data->promiscuous =3D 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 !=3D NULL) { > + rte_free(eth_dev->data->mac_addrs); > + rte_eth_dev_release_port(eth_dev); > + } > return -1; > } >=20 > -- > 1.9.1