net/vdev_netvsc: fix device cast
authorStephen Hemminger <stephen@networkplumber.org>
Wed, 13 Mar 2019 02:12:53 +0000 (19:12 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 29 Mar 2019 16:25:31 +0000 (17:25 +0100)
The return value from bus->find_device is a rte_device
which is not safe to cast to a rte_vdev_device structure.
It doesn't really matter since only being checked for NULL
but static checkers might find a bug here.

Fixes: 56252de779a6 ("net/vdev_netvsc: add automatic probing")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Matan Azrad <matan@mellanox.com>
drivers/net/vdev_netvsc/vdev_netvsc.c

index ba63fac..801f54c 100644 (file)
@@ -808,7 +808,7 @@ vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
 static void
 vdev_netvsc_scan_callback(__rte_unused void *arg)
 {
-       struct rte_vdev_device *dev;
+       struct rte_device *dev;
        struct rte_devargs *devargs;
        struct rte_bus *vbus = rte_bus_find_by_name("vdev");
 
@@ -816,8 +816,9 @@ vdev_netvsc_scan_callback(__rte_unused void *arg)
                if (!strncmp(devargs->name, VDEV_NETVSC_DRIVER_NAME,
                             VDEV_NETVSC_DRIVER_NAME_LEN))
                        return;
-       dev = (struct rte_vdev_device *)vbus->find_device(NULL,
-               vdev_netvsc_cmp_rte_device, VDEV_NETVSC_DRIVER_NAME);
+
+       dev = vbus->find_device(NULL, vdev_netvsc_cmp_rte_device,
+                               VDEV_NETVSC_DRIVER_NAME);
        if (dev)
                return;
        if (rte_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME))