Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit fd94986

Browse files
mstsirkingregkh
authored andcommitted
virtio_console: fix misc probe bugs
[ Upstream commit b9efbe2 ] This fixes the following issue discovered by code review: after vqs have been created, a buggy device can send an interrupt. A control vq callback will then try to schedule control_work which has not been initialized yet. Similarly for config interrupt. Further, in and out vq callbacks invoke find_port_by_vq which attempts to take ports_lock which also has not been initialized. To fix, init all locks and work before creating vqs. Message-ID: <ad982e975a6160ad110c623c016041311ca15b4f.1726511547.git.mst@redhat.com> Fixes: 17634ba ("virtio: console: Add a new MULTIPORT feature, support for generic ports") Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5e20797 commit fd94986

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

drivers/char/virtio_console.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -2052,25 +2052,27 @@ static int virtcons_probe(struct virtio_device *vdev)
20522052
multiport = true;
20532053
}
20542054

2055-
err = init_vqs(portdev);
2056-
if (err < 0) {
2057-
dev_err(&vdev->dev, "Error %d initializing vqs\n", err);
2058-
goto free_chrdev;
2059-
}
2060-
20612055
spin_lock_init(&portdev->ports_lock);
20622056
INIT_LIST_HEAD(&portdev->ports);
20632057
INIT_LIST_HEAD(&portdev->list);
20642058

2065-
virtio_device_ready(portdev->vdev);
2066-
20672059
INIT_WORK(&portdev->config_work, &config_work_handler);
20682060
INIT_WORK(&portdev->control_work, &control_work_handler);
20692061

20702062
if (multiport) {
20712063
spin_lock_init(&portdev->c_ivq_lock);
20722064
spin_lock_init(&portdev->c_ovq_lock);
2065+
}
20732066

2067+
err = init_vqs(portdev);
2068+
if (err < 0) {
2069+
dev_err(&vdev->dev, "Error %d initializing vqs\n", err);
2070+
goto free_chrdev;
2071+
}
2072+
2073+
virtio_device_ready(portdev->vdev);
2074+
2075+
if (multiport) {
20742076
err = fill_queue(portdev->c_ivq, &portdev->c_ivq_lock);
20752077
if (err < 0) {
20762078
dev_err(&vdev->dev,

0 commit comments

Comments
 (0)