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 365867D36 for ; Wed, 26 Jul 2017 19:06:58 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2017 10:06:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,416,1496127600"; d="scan'208";a="1155665158" Received: from dwdohert-mobl1.ger.corp.intel.com (HELO [163.33.228.138]) ([163.33.228.138]) by orsmga001.jf.intel.com with ESMTP; 26 Jul 2017 10:06:56 -0700 To: Tomasz Kulasek , dev@dpdk.org References: <20170726155048.10648-1-tomaszx.kulasek@intel.com> From: Declan Doherty Message-ID: <31a717db-a089-7567-bb5b-49f6693cf343@intel.com> Date: Wed, 26 Jul 2017 18:06:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170726155048.10648-1-tomaszx.kulasek@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] bonding: fix segfault when primary slave set X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jul 2017 17:06:59 -0000 On 26/07/2017 4:50 PM, Tomasz Kulasek wrote: > rte_eth_bond_primary_set segfaults for invalid port. This patch moves > devices check before use of internal data. > > Fixes: 4c42498d916d ("net/bonding: allow slaves to also be bonded devices") > > Signed-off-by: Tomasz Kulasek > --- > drivers/net/bonding/rte_eth_bond_api.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c > index 824ab4f..de1d9e0 100644 > --- a/drivers/net/bonding/rte_eth_bond_api.c > +++ b/drivers/net/bonding/rte_eth_bond_api.c > @@ -514,15 +514,14 @@ > { > struct bond_dev_private *internals; > > - internals = rte_eth_devices[bonded_port_id].data->dev_private; > - > if (valid_bonded_port_id(bonded_port_id) != 0) > return -1; > > + internals = rte_eth_devices[bonded_port_id].data->dev_private; > + > if (valid_slave_port_id(slave_port_id, internals->mode) != 0) > return -1; > > - > internals->user_defined_primary_port = 1; > internals->primary_port = slave_port_id; > > Acked-by: Declan Doherty