From: Maxime Coquelin Date: Fri, 26 Jun 2020 14:04:29 +0000 (+0200) Subject: bus/fslmc: fix iterating on a class type X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=44255245433b3b4394474db100d478341aeb08fc bus/fslmc: fix iterating on a class type 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: e67a61614d0b ("bus/fslmc: support device iteration") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Acked-by: Adrián Moreno --- diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index afbd82e8db..ac46eb4fe8 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -603,6 +603,11 @@ fslmc_bus_dev_iterate(const void *start, const char *str, struct rte_dpaa2_device *dev; char *dup, *dev_name = NULL; + if (str == NULL) { + DPAA2_BUS_DEBUG("No device string"); + return NULL; + } + /* Expectation is that device would be name=device_name */ if (strncmp(str, "name=", 5) != 0) { DPAA2_BUS_DEBUG("Invalid device string (%s)\n", str);