virtio-mmio: add error check for platform_get_irq
authorIhor Matushchak <ihor.matushchak@foobox.net>
Tue, 2 Jul 2019 14:48:18 +0000 (17:48 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 11 Jul 2019 20:22:29 +0000 (16:22 -0400)
in vm_find_vqs() irq has a wrong type
so, in case of no IRQ resource defined,
wrong parameter will be passed to request_irq()

Signed-off-by: Ihor Matushchak <ihor.matushchak@foobox.net>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Ivan T. Ivanov <iivanov.xz@gmail.com>
drivers/virtio/virtio_mmio.c

index f363fbeb5ab0cf0c3e006de5c4d9e724c0cb5691..e09edb5c5e0653dad74bb765e1c88d6d7535e04d 100644 (file)
@@ -463,9 +463,14 @@ static int vm_find_vqs(struct virtio_device *vdev, unsigned nvqs,
                       struct irq_affinity *desc)
 {
        struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
-       unsigned int irq = platform_get_irq(vm_dev->pdev, 0);
+       int irq = platform_get_irq(vm_dev->pdev, 0);
        int i, err, queue_idx = 0;
 
+       if (irq < 0) {
+               dev_err(&vdev->dev, "Cannot get IRQ resource\n");
+               return irq;
+       }
+
        err = request_irq(irq, vm_interrupt, IRQF_SHARED,
                        dev_name(&vdev->dev), vm_dev);
        if (err)