[RFC PATCH 15/15] 9p/trans_virtio: Handle virtio_device_ready() failure

From: Xie Yongji
Date: Mon May 17 2021 - 05:37:33 EST


Now virtio_device_ready() will return error if we get
invalid status. Let's handle this case on probe.

Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx>
---
net/9p/trans_virtio.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 0960ed1ad7ac..6013d3761b76 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -617,7 +617,9 @@ static int p9_virtio_probe(struct virtio_device *vdev)
/* Ceiling limit to avoid denial of service attacks */
chan->p9_max_pages = nr_free_buffer_pages()/4;

- virtio_device_ready(vdev);
+ err = virtio_device_ready(vdev);
+ if (err)
+ goto out_free_vc_wq;

mutex_lock(&virtio_9p_lock);
list_add_tail(&chan->chan_list, &virtio_chan_list);
@@ -628,6 +630,8 @@ static int p9_virtio_probe(struct virtio_device *vdev)

return 0;

+out_free_vc_wq:
+ kfree(chan->vc_wq);
out_remove_file:
sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
out_free_tag:
--
2.11.0