From patchwork Wed Jul 26 15:50:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Kulasek X-Patchwork-Id: 27225 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 CCA887D0A; Wed, 26 Jul 2017 17:52:50 +0200 (CEST) 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Declan Doherty --- 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;