[PATCH-for-8.2] backends/cryptodev: Do not ignore throttle/backends Errors

Philippe Mathieu-Daudé posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231120145835.92030-1-philmd@linaro.org
Maintainers: "Gonglei (Arei)" <arei.gonglei@huawei.com>, Zhenwei Pi <pizhenwei@bytedance.com>
There is a newer version of this series
backends/cryptodev.c | 10 ++++++++++
1 file changed, 10 insertions(+)
[PATCH-for-8.2] backends/cryptodev: Do not ignore throttle/backends Errors
Posted by Philippe Mathieu-Daudé 1 year ago
Both cryptodev_backend_set_throttle() and CryptoDevBackendClass::init()
can set their Error** argument. Do not ignore them, return early on
failure.

Cc: qemu-stable@nongnu.org
Fixes: e7a775fd9f ("cryptodev: Account statistics")
Fixes: 2580b452ff ("cryptodev: support QoS")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 backends/cryptodev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index e5006bd215..c0b2abc943 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -398,6 +398,7 @@ static void cryptodev_backend_set_ops(Object *obj, Visitor *v,
 static void
 cryptodev_backend_complete(UserCreatable *uc, Error **errp)
 {
+    ERRP_GUARD();
     CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
     CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
     uint32_t services;
@@ -406,11 +407,20 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
     QTAILQ_INIT(&backend->opinfos);
     value = backend->tc.buckets[THROTTLE_OPS_TOTAL].avg;
     cryptodev_backend_set_throttle(backend, THROTTLE_OPS_TOTAL, value, errp);
+    if (!errp) {
+        return;
+    }
     value = backend->tc.buckets[THROTTLE_BPS_TOTAL].avg;
     cryptodev_backend_set_throttle(backend, THROTTLE_BPS_TOTAL, value, errp);
+    if (!errp) {
+        return;
+    }
 
     if (bc->init) {
         bc->init(backend, errp);
+        if (!errp) {
+            return;
+        }
     }
 
     services = backend->conf.crypto_services;
-- 
2.41.0


Re: [PATCH-for-8.2] backends/cryptodev: Do not ignore throttle/backends Errors
Posted by Philippe Mathieu-Daudé 1 year ago
On 20/11/23 15:58, Philippe Mathieu-Daudé wrote:
> Both cryptodev_backend_set_throttle() and CryptoDevBackendClass::init()
> can set their Error** argument. Do not ignore them, return early on
> failure.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: e7a775fd9f ("cryptodev: Account statistics")
> Fixes: 2580b452ff ("cryptodev: support QoS")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   backends/cryptodev.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/backends/cryptodev.c b/backends/cryptodev.c
> index e5006bd215..c0b2abc943 100644
> --- a/backends/cryptodev.c
> +++ b/backends/cryptodev.c
> @@ -398,6 +398,7 @@ static void cryptodev_backend_set_ops(Object *obj, Visitor *v,
>   static void
>   cryptodev_backend_complete(UserCreatable *uc, Error **errp)
>   {
> +    ERRP_GUARD();
>       CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
>       CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
>       uint32_t services;
> @@ -406,11 +407,20 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
>       QTAILQ_INIT(&backend->opinfos);
>       value = backend->tc.buckets[THROTTLE_OPS_TOTAL].avg;
>       cryptodev_backend_set_throttle(backend, THROTTLE_OPS_TOTAL, value, errp);
> +    if (!errp) {

Posted too quick, sorry. V2 coming...
> +        return;
> +    }