From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 80A8C5A98 for ; Wed, 26 Jul 2017 17:52:49 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP; 26 Jul 2017 08:52:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,416,1496127600"; d="scan'208";a="1176681377" Received: from unknown (HELO Sent) ([10.103.102.148]) by fmsmga001.fm.intel.com with SMTP; 26 Jul 2017 08:52:42 -0700 Received: by Sent (sSMTP sendmail emulation); Wed, 26 Jul 2017 17:50:53 +0200 From: Tomasz Kulasek To: dev@dpdk.org Cc: declan.doherty@intel.com Date: Wed, 26 Jul 2017 17:50:48 +0200 Message-Id: <20170726155048.10648-1-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.12.3 Subject: [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 15:52:50 -0000 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; -- 1.9.1