[PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()

Markus Armbruster posted 46 patches 5 years, 5 months ago
There is a newer version of this series
[PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()
Posted by Markus Armbruster 5 years, 5 months ago
virtio_crypto_pci_realize() continues after realization of its
"virtio-crypto-device" fails.  Only an object_property_set_link()
follows; looks harmless to me.  Tidy up anyway: return after failure,
just like virtio_rng_pci_realize() does.

Cc: "Gonglei (Arei)" <arei.gonglei@huawei.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/virtio/virtio-crypto-pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c
index 72be531c95..0755722288 100644
--- a/hw/virtio/virtio-crypto-pci.c
+++ b/hw/virtio/virtio-crypto-pci.c
@@ -54,7 +54,9 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
     }
 
     virtio_pci_force_virtio_1(vpci_dev);
-    qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
+    if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) {
+        return;
+    }
     object_property_set_link(OBJECT(vcrypto),
                  OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev",
                  NULL);
-- 
2.26.2


Re: [PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()
Posted by Eric Blake 5 years, 5 months ago
On 6/24/20 11:43 AM, Markus Armbruster wrote:
> virtio_crypto_pci_realize() continues after realization of its
> "virtio-crypto-device" fails.  Only an object_property_set_link()
> follows; looks harmless to me.  Tidy up anyway: return after failure,
> just like virtio_rng_pci_realize() does.
> 
> Cc: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   hw/virtio/virtio-crypto-pci.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c
> index 72be531c95..0755722288 100644
> --- a/hw/virtio/virtio-crypto-pci.c
> +++ b/hw/virtio/virtio-crypto-pci.c
> @@ -54,7 +54,9 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
>       }
>   
>       virtio_pci_force_virtio_1(vpci_dev);
> -    qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
> +    if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) {
> +        return;
> +    }
>       object_property_set_link(OBJECT(vcrypto),
>                    OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev",
>                    NULL);
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


RE: [PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()
Posted by Gonglei (Arei) 5 years, 5 months ago
> -----Original Message-----
> From: Markus Armbruster [mailto:armbru@redhat.com]
> Sent: Thursday, June 25, 2020 12:43 AM
> To: qemu-devel@nongnu.org
> Cc: pbonzini@redhat.com; berrange@redhat.com; ehabkost@redhat.com;
> qemu-block@nongnu.org; peter.maydell@linaro.org;
> vsementsov@virtuozzo.com; Gonglei (Arei) <arei.gonglei@huawei.com>;
> Michael S . Tsirkin <mst@redhat.com>
> Subject: [PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()
> 
> virtio_crypto_pci_realize() continues after realization of its "virtio-crypto-device"
> fails.  Only an object_property_set_link() follows; looks harmless to me.  Tidy
> up anyway: return after failure, just like virtio_rng_pci_realize() does.
> 
> Cc: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/virtio/virtio-crypto-pci.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 

Reviewed-by: Gonglei < arei.gonglei@huawei.com>

> diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c index
> 72be531c95..0755722288 100644
> --- a/hw/virtio/virtio-crypto-pci.c
> +++ b/hw/virtio/virtio-crypto-pci.c
> @@ -54,7 +54,9 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy
> *vpci_dev, Error **errp)
>      }
> 
>      virtio_pci_force_virtio_1(vpci_dev);
> -    qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
> +    if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) {
> +        return;
> +    }
>      object_property_set_link(OBJECT(vcrypto),
>                   OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev",
>                   NULL);
> --
> 2.26.2


Re: [PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()
Posted by Vladimir Sementsov-Ogievskiy 5 years, 5 months ago
24.06.2020 19:43, Markus Armbruster wrote:
> virtio_crypto_pci_realize() continues after realization of its
> "virtio-crypto-device" fails.  Only an object_property_set_link()
> follows; looks harmless to me.  Tidy up anyway: return after failure,
> just like virtio_rng_pci_realize() does.
> 
> Cc: "Gonglei (Arei)"<arei.gonglei@huawei.com>
> Cc: Michael S. Tsirkin<mst@redhat.com>
> Signed-off-by: Markus Armbruster<armbru@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

-- 
Best regards,
Vladimir