diff mbox series

backends/cryptodev-vhost-user: Fix local_error leaks

Message ID DM8PR13MB5078933D25141B3F23ECA782B3022@DM8PR13MB5078.namprd13.prod.outlook.com (mailing list archive)
State New
Headers show
Series backends/cryptodev-vhost-user: Fix local_error leaks | expand

Commit Message

Gabriel Barrantes Dec. 23, 2024, 11:46 p.m. UTC
From c808fa797942b9bd32221594b7eef690a7558b14 Mon Sep 17 00:00:00 2001
From: Gabriel Barrantes <gabriel.barrantes.dev@outlook.com>
Date: Mon, 23 Dec 2024 14:58:12 -0600
Subject: [PATCH] backends/cryptodev-vhost-user: Fix local_error leaks

Do not propagate error to the upper, directly output the error to
avoid leaks.

Closes: #2714

Signed-off-by: Gabriel Barrantes <gabriel.barrantes.dev@outlook.com>
---
backends/cryptodev-vhost-user.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--
2.43.0

Comments

Philippe Mathieu-Daudé Dec. 24, 2024, 8:59 a.m. UTC | #1
Hi Gabriel,

On 24/12/24 00:46, Gabriel Barrantes wrote:
>  From c808fa797942b9bd32221594b7eef690a7558b14 Mon Sep 17 00:00:00 2001
> From: Gabriel Barrantes <gabriel.barrantes.dev@outlook.com>
> Date: Mon, 23 Dec 2024 14:58:12 -0600
> Subject: [PATCH] backends/cryptodev-vhost-user: Fix local_error leaks
> 
> Do not propagate error to the upper, directly output the error to
> avoid leaks.
> 
> Closes: #2714

Better to use the full issue url to ease downstream backports
where this commit is cherry-picked:

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2714

Fixes: 2fda101de07 ("virtio-crypto: Support asynchronous mode")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> 
> Signed-off-by: Gabriel Barrantes <gabriel.barrantes.dev@outlook.com>
> ---
> backends/cryptodev-vhost-user.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost- 
> user.c
> index 43efdf9747..09bfbddb47 100644
> --- a/backends/cryptodev-vhost-user.c
> +++ b/backends/cryptodev-vhost-user.c
> @@ -281,8 +281,8 @@ static int cryptodev_vhost_user_create_session(
>          break;
> 
>      default:
> -        error_setg(&local_error, "Unsupported opcode :%" PRIu32 "",
> -                   sess_info->op_code);
> +        error_report("Unsupported opcode :%" PRIu32 "",
> +                     sess_info->op_code);
>          return -VIRTIO_CRYPTO_NOTSUPP;
>      }

Arei, Pi, Having CryptoDevBackendClass::create_session() take an errp
argument would simplify the call chain, reporting the error once in
cryptodev_backend_create_session().

> 
> -- 
> 2.43.0
> 
>
diff mbox series

Patch

diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index 43efdf9747..09bfbddb47 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -281,8 +281,8 @@  static int cryptodev_vhost_user_create_session(
        break;

    default:
-        error_setg(&local_error, "Unsupported opcode :%" PRIu32 "",
-                   sess_info->op_code);
+        error_report("Unsupported opcode :%" PRIu32 "",
+                     sess_info->op_code);
        return -VIRTIO_CRYPTO_NOTSUPP;
    }