bus/dpaa: fix iterating on a class type
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Fri, 26 Jun 2020 14:04:28 +0000 (16:04 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 30 Jun 2020 12:52:30 +0000 (14:52 +0200)
This patches fixes a null pointer dereferencing that happens
when the device string passed to the iterator is NULL. This
situation can happen when iterating on a class type.
For example:

RTE_DEV_FOREACH(dev, "class=eth", &dev_iter) {
    ...
}

Fixes: e79df833d3f6 ("bus/dpaa: support hotplug ops")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Adrián Moreno <amorenoz@redhat.com>
drivers/bus/dpaa/dpaa_bus.c

index d53fe60..591e28c 100644 (file)
@@ -703,6 +703,11 @@ dpaa_bus_dev_iterate(const void *start, const char *str,
        struct rte_dpaa_device *dev;
        char *dup, *dev_name = NULL;
 
+       if (str == NULL) {
+               DPAA_BUS_DEBUG("No device string");
+               return NULL;
+       }
+
        /* Expectation is that device would be name=device_name */
        if (strncmp(str, "name=", 5) != 0) {
                DPAA_BUS_DEBUG("Invalid device string (%s)\n", str);