[01/14] bus/dpaa: fix null pointer dereference
diff mbox series

Message ID 20200611213748.1967029-2-maxime.coquelin@redhat.com
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show
Series
  • vDPA API and framework rework
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Maxime Coquelin June 11, 2020, 9:37 p.m. UTC
This patches fixes a null pointer derefencing 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
Cc: shreyansh.jain@nxp.com

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/bus/dpaa/dpaa_bus.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Gaetan Rivet June 12, 2020, 9:48 a.m. UTC | #1
On 11/06/20 23:37 +0200, Maxime Coquelin wrote:
> This patches fixes a null pointer derefencing 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) {
>     ...
> }
> 

Given this fix and the next, this seems like an oversight / bug from the
iterator actually.  Those two fixes are still correct but the root cause
should be addressed.

> Fixes: e79df833d3f6 ("bus/dpaa: support hotplug ops")
> Cc: stable@dpdk.org
> Cc: shreyansh.jain@nxp.com
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  drivers/bus/dpaa/dpaa_bus.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
> index d53fe6083a..216f38acd4 100644
> --- a/drivers/bus/dpaa/dpaa_bus.c
> +++ b/drivers/bus/dpaa/dpaa_bus.c
> @@ -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\n");
> +		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);
> -- 
> 2.26.2
>

Patch
diff mbox series

diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index d53fe6083a..216f38acd4 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -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\n");
+		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);