Messages in this thread Patch in this message | | | From | Xie Yongji <> | Subject | [RFC PATCH 03/15] virtio_console: Handle virtio_device_ready() failure | Date | Mon, 17 May 2021 17:34:16 +0800 |
| |
Now virtio_device_ready() will return error if we get invalid status. Let's handle this case in both probe and resume paths.
Signed-off-by: Xie Yongji <xieyongji@bytedance.com> --- drivers/char/virtio_console.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index b85abe1eb2d1..1c40ca6d76ba 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2048,7 +2048,11 @@ static int virtcons_probe(struct virtio_device *vdev) INIT_LIST_HEAD(&portdev->ports); INIT_LIST_HEAD(&portdev->list); - virtio_device_ready(portdev->vdev); + err = virtio_device_ready(portdev->vdev); + if (err) { + dev_err(&vdev->dev, "Error %d enable virtio device\n", err); + goto free_vqs; + } INIT_WORK(&portdev->config_work, &config_work_handler); INIT_WORK(&portdev->control_work, &control_work_handler); @@ -2100,6 +2104,8 @@ static int virtcons_probe(struct virtio_device *vdev) return 0; +free_vqs: + remove_vqs(portdev); free_chrdev: unregister_chrdev(portdev->chr_major, "virtio-portsdev"); free: @@ -2178,7 +2184,11 @@ static int virtcons_restore(struct virtio_device *vdev) if (ret) return ret; - virtio_device_ready(portdev->vdev); + ret = virtio_device_ready(portdev->vdev); + if (ret) { + remove_vqs(portdev); + return ret; + } if (use_multiport(portdev)) fill_queue(portdev->c_ivq, &portdev->c_ivq_lock); -- 2.11.0
| |