[RFC PATCH 04/15] virtio_crypto: Handle virtio_device_ready() failure

From: Xie Yongji
Date: Mon May 17 2021 - 05:35:13 EST


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@xxxxxxxxxxxxx>
---
drivers/crypto/virtio/virtio_crypto_core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/virtio/virtio_crypto_core.c b/drivers/crypto/virtio/virtio_crypto_core.c
index 080955a1dd9c..18f7ffc37738 100644
--- a/drivers/crypto/virtio/virtio_crypto_core.c
+++ b/drivers/crypto/virtio/virtio_crypto_core.c
@@ -393,7 +393,9 @@ static int virtcrypto_probe(struct virtio_device *vdev)
if (err)
goto free_vqs;

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

err = virtcrypto_update_status(vcrypto);
if (err)
@@ -479,7 +481,9 @@ static int virtcrypto_restore(struct virtio_device *vdev)
if (err)
goto free_vqs;

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

err = virtcrypto_dev_start(vcrypto);
if (err) {
--
2.11.0