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 1340B4D3A for ; Mon, 22 Oct 2018 07:48:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Oct 2018 22:48:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,410,1534834800"; d="scan'208";a="83077363" Received: from dpdk51.sh.intel.com ([10.67.110.190]) by orsmga007.jf.intel.com with ESMTP; 21 Oct 2018 22:48:25 -0700 From: Qi Zhang To: thomas@monjalon.net Cc: dev@dpdk.org, Qi Zhang Date: Mon, 22 Oct 2018 13:49:32 +0800 Message-Id: <20181022054932.39052-1-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 Subject: [dpdk-dev] [PATCH] eal: fix floating device argument pointer 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: Mon, 22 Oct 2018 05:48:27 -0000 After we insert a devargs into devargs_list, following bus->scan may destroy it due to another rte_devargs_insert. Its better not to use a devargs pointer after it has been inserted. Fixes: 911462eb4a5f ("eal: simplify parameters of hotplug functions") Signed-off-by: Qi Zhang --- lib/librte_eal/common/eal_common_dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 8b0844af1..d4b1ea70d 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -185,6 +185,7 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev) { struct rte_device *dev; struct rte_devargs *da; + struct rte_devargs da_cp; int ret; *new_dev = NULL; @@ -203,18 +204,23 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev) goto err_devarg; } + /** + * its better not to use da after rte_devargs_insert, + * so make a copy here. + */ + da_cp = *da; ret = rte_devargs_insert(da); if (ret) goto err_devarg; - ret = da->bus->scan(); + ret = da_cp.bus->scan(); if (ret) goto err_devarg; - dev = da->bus->find_device(NULL, cmp_dev_name, da->name); + dev = da_cp.bus->find_device(NULL, cmp_dev_name, da_cp.name); if (dev == NULL) { RTE_LOG(ERR, EAL, "Cannot find device (%s)\n", - da->name); + da_cp.name); ret = -ENODEV; goto err_devarg; } -- 2.13.6