]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: fix matching of generic virtio device
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 3 May 2023 13:06:26 +0000 (15:06 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 3 May 2023 13:06:26 +0000 (15:06 +0200)
The strings won't be an exact match, as we are only looking to match the
prefix here, i.e. "virtio,device". This is already done properly in
libxl_virtio.c file, lets do the same here too.

Fixes: 43ba5202e2ee ("libxl: add support for generic virtio device")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
tools/libs/light/libxl_arm.c

index ddc7b2a15975cc3c4d6d35ffc11106235c84d449..97c80d7ed0fa1cae4092194570315d929e43ad25 100644 (file)
@@ -1033,10 +1033,14 @@ static int make_virtio_mmio_node_device(libxl__gc *gc, void *fdt, uint64_t base,
     } else if (!strcmp(type, VIRTIO_DEVICE_TYPE_GPIO)) {
         res = make_virtio_mmio_node_gpio(gc, fdt);
         if (res) return res;
-    } else if (strcmp(type, VIRTIO_DEVICE_TYPE_GENERIC)) {
-        /* Doesn't match generic virtio device */
-        LOG(ERROR, "Invalid type for virtio device: %s", type);
-        return -EINVAL;
+    } else {
+        int len = sizeof(VIRTIO_DEVICE_TYPE_GENERIC) - 1;
+
+        if (strncmp(type, VIRTIO_DEVICE_TYPE_GENERIC, len)) {
+            /* Doesn't match generic virtio device */
+            LOG(ERROR, "Invalid type for virtio device: %s", type);
+            return -EINVAL;
+        }
     }
 
     return fdt_end_node(fdt);