⬢ DragonFlyBSD Kernel Audit
DF-4425 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/virtual/virtio/block/virtio_blk.c
+++ b/sys/dev/virtual/virtio/block/virtio_blk.c
@@ -289,6 +289,11 @@ vtblk_attach(device_t dev)
 	if (virtio_with_feature(dev, VIRTIO_BLK_F_MQ)) {
 		int max_queues =
 		    vtblk_tunable_int(sc, "max_queues", vtblk_max_queues);
+		if (blkcfg.num_queues < 1) {
+			error = EINVAL;
+			device_printf(dev, "invalid num_queues: 0\n");
+			return error;
+		}
 		sc->vtblk_nqs = min(blkcfg.num_queues, ncpus);