DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: fix floating device argument pointer
@ 2018-10-22  5:49 Qi Zhang
  2018-10-22  7:25 ` Thomas Monjalon
  0 siblings, 1 reply; 7+ messages in thread
From: Qi Zhang @ 2018-10-22  5:49 UTC (permalink / raw)
  To: thomas; +Cc: dev, Qi Zhang

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 <qi.z.zhang@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-25  9:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-22  5:49 [dpdk-dev] [PATCH] eal: fix floating device argument pointer Qi Zhang
2018-10-22  7:25 ` Thomas Monjalon
2018-10-23 22:39   ` Gaëtan Rivet
2018-10-24 14:43     ` Thomas Monjalon
2018-10-24 15:33       ` Gaëtan Rivet
2018-10-25  3:22         ` Zhang, Qi Z
2018-10-25  9:42           ` Gaëtan Rivet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).