[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210517093428.670-4-xieyongji@bytedance.com>
Date: Mon, 17 May 2021 17:34:16 +0800
From: Xie Yongji <xieyongji@...edance.com>
To: mst@...hat.com, jasowang@...hat.com, stefanha@...hat.com
Cc: amit@...nel.org, arei.gonglei@...wei.com, airlied@...ux.ie,
kraxel@...hat.com, jean-philippe@...aro.org, ohad@...ery.com,
bjorn.andersson@...aro.org, david@...hat.com, vgoyal@...hat.com,
miklos@...redi.hu, lucho@...kov.net, asmadeus@...ewreck.org,
virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 03/15] virtio_console: Handle virtio_device_ready() failure
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@...edance.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
Powered by blists - more mailing lists