Skip to content

Commit 62ca18a

Browse files
committed
virtio-mmio: Reject invalid IRQ 0 command line argument
The "virtio_mmio.device=" command line argument allows a user to specify the size, address, and IRQ of a virtio device. Previously the only requirement for the IRQ was that it be an unsigned integer. Zero is an unsigned integer but an invalid IRQ number, and after a85a6c8 ("driver core: platform: Clarify that IRQ 0 is invalid"), attempts to use IRQ 0 cause warnings. If the user specifies IRQ 0, return failure instead of registering a device with IRQ 0. Fixes: a85a6c8 ("driver core: platform: Clarify that IRQ 0 is invalid") Signed-off-by: Bjorn Helgaas <[email protected]> Acked-by: Jason Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]>
1 parent 5396956 commit 62ca18a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/virtio/virtio_mmio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,11 @@ static int vm_cmdline_set(const char *device,
641641
&vm_cmdline_id, &consumed);
642642

643643
/*
644-
* sscanf() must processes at least 2 chunks; also there
644+
* sscanf() must process at least 2 chunks; also there
645645
* must be no extra characters after the last chunk, so
646646
* str[consumed] must be '\0'
647647
*/
648-
if (processed < 2 || str[consumed])
648+
if (processed < 2 || str[consumed] || irq == 0)
649649
return -EINVAL;
650650

651651
resources[0].flags = IORESOURCE_MEM;

0 commit comments

Comments
 (0)