53 lines
2.0 KiB
Diff
53 lines
2.0 KiB
Diff
|
|
From ca3f4fd234ea4b8f02a415b99b449e71d028c076 Mon Sep 17 00:00:00 2001
|
||
|
|
From: qihao_yewu <qihao_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Tue, 8 Apr 2025 07:27:47 -0400
|
||
|
|
Subject: [PATCH] cryptodev: Fix error handling in
|
||
|
|
cryptodev_lkcf_execute_task()
|
||
|
|
|
||
|
|
cheery-pick from 1c89dfefc4c33295126208225f202f39b5a234c3
|
||
|
|
|
||
|
|
When cryptodev_lkcf_set_op_desc() fails, we report an error, but
|
||
|
|
continue anyway. This is wrong. We then pass a non-null @local_error
|
||
|
|
to various functions, which could easily fail error_setv()'s assertion
|
||
|
|
on failure.
|
||
|
|
|
||
|
|
Fail the function instead.
|
||
|
|
|
||
|
|
When qcrypto_akcipher_new() fails, we fail the function without
|
||
|
|
reporting the error. This leaks the Error object.
|
||
|
|
|
||
|
|
Add the missing error reporting. This also frees the Error object.
|
||
|
|
|
||
|
|
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
||
|
|
Message-ID: <20250312101131.1615777-1-armbru@redhat.com>
|
||
|
|
Reviewed-by: zhenwei pi <pizhenwei@bytedance.com>
|
||
|
|
Signed-off-by: qihao_yewu <qihao_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
backends/cryptodev-lkcf.c | 3 +++
|
||
|
|
1 file changed, 3 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
|
||
|
|
index 45aba1ff67..45b287a953 100644
|
||
|
|
--- a/backends/cryptodev-lkcf.c
|
||
|
|
+++ b/backends/cryptodev-lkcf.c
|
||
|
|
@@ -330,6 +330,8 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTask *task)
|
||
|
|
cryptodev_lkcf_set_op_desc(&session->akcipher_opts, op_desc,
|
||
|
|
sizeof(op_desc), &local_error) != 0) {
|
||
|
|
error_report_err(local_error);
|
||
|
|
+ status = -VIRTIO_CRYPTO_ERR;
|
||
|
|
+ goto out;
|
||
|
|
} else {
|
||
|
|
key_id = add_key(KCTL_KEY_TYPE_PKEY, "lkcf-backend-priv-key",
|
||
|
|
p8info, p8info_len, KCTL_KEY_RING);
|
||
|
|
@@ -346,6 +348,7 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTask *task)
|
||
|
|
session->key, session->keylen,
|
||
|
|
&local_error);
|
||
|
|
if (!akcipher) {
|
||
|
|
+ error_report_err(local_error);
|
||
|
|
status = -VIRTIO_CRYPTO_ERR;
|
||
|
|
goto out;
|
||
|
|
}
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|