From: Bruce Richardson Date: Mon, 25 Nov 2019 16:47:41 +0000 (+0000) Subject: examples/ioat: fix possible null dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1fe0bd0acdc39755591008104971b92be11f59a7;p=dpdk.git examples/ioat: fix possible null dereference When searching for raw devices with the correct type, we check the driver name using strcmp, without first checking that the call to info get succeeded and assigned a value to that pointer. If the call to get the device info fails, we can treat it as if the device didn't match, and continue the loop, so the easiest fix is just to skip the strcmp if the driver_name is null. [A non-null value from a previous failed match is ok as it too causes the same behaviour of another loop iteration]. Coverity issue: 350353 Fixes: 2328542ed84e ("examples/ioat: add rawdev copy mode") Signed-off-by: Bruce Richardson --- diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c index a0cc5c496e..e9117718fe 100644 --- a/examples/ioat/ioatfwd.c +++ b/examples/ioat/ioatfwd.c @@ -751,8 +751,9 @@ assign_rawdevs(void) if (rdev_id == rte_rawdev_count()) goto end; rte_rawdev_info_get(rdev_id++, &rdev_info); - } while (strcmp(rdev_info.driver_name, - IOAT_PMD_RAWDEV_NAME_STR) != 0); + } while (rdev_info.driver_name == NULL || + strcmp(rdev_info.driver_name, + IOAT_PMD_RAWDEV_NAME_STR) != 0); cfg.ports[i].ioat_ids[j] = rdev_id - 1; configure_rawdev_queue(cfg.ports[i].ioat_ids[j]);