[dpdk-stable] patch 'bus/vdev: fix find device implementation' has been queued to stable release 18.02.2
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Mon Apr 30 16:53:21 CEST 2018
Hi,
FYI, your patch has been queued to stable release 18.02.2
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/02/18. So please
shout if anyone has objections.
Thanks.
Luca Boccassi
---
>From c2afaf6b85b6d55dee13c3742baf2052d7994a9d Mon Sep 17 00:00:00 2001
From: Gaetan Rivet <gaetan.rivet at 6wind.com>
Date: Fri, 27 Apr 2018 16:13:06 +0200
Subject: [PATCH] bus/vdev: fix find device implementation
[ upstream commit 3701b792a8a3bce519adc979d5cc8d127231fd48 ]
If start is set and a device before it matches the data,
this device is returned.
This induces potentially infinite loops.
Fixes: c7fe1eea8a74 ("bus: simplify finding starting point")
Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
---
drivers/bus/vdev/rte_bus_vdev.h | 3 +++
drivers/bus/vdev/vdev.c | 16 ++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vdev.h
index f9d8a2383..4da9967c6 100644
--- a/drivers/bus/vdev/rte_bus_vdev.h
+++ b/drivers/bus/vdev/rte_bus_vdev.h
@@ -53,6 +53,9 @@ struct rte_vdev_device {
#define RTE_DEV_TO_VDEV(ptr) \
container_of(ptr, struct rte_vdev_device, device)
+#define RTE_DEV_TO_VDEV_CONST(ptr) \
+ container_of(ptr, const struct rte_vdev_device, device)
+
static inline const char *
rte_vdev_device_name(const struct rte_vdev_device *dev)
{
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 7eae319cb..914073d12 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -386,15 +386,19 @@ static struct rte_device *
vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
const void *data)
{
+ const struct rte_vdev_device *vstart;
struct rte_vdev_device *dev;
- TAILQ_FOREACH(dev, &vdev_device_list, next) {
- if (start && &dev->device == start) {
- start = NULL;
- continue;
- }
+ if (start != NULL) {
+ vstart = RTE_DEV_TO_VDEV_CONST(start);
+ dev = TAILQ_NEXT(vstart, next);
+ } else {
+ dev = TAILQ_FIRST(&vdev_device_list);
+ }
+ while (dev != NULL) {
if (cmp(&dev->device, data) == 0)
- return &dev->device;
+ break;
+ dev = TAILQ_NEXT(dev, next);
}
return NULL;
}
--
2.14.2
More information about the stable
mailing list