From: zhenwei pi <pizhenwei@bytedance.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: arei.gonglei@huawei.com
Subject: Re: [PATCH] cryptodev: Fix error handling in cryptodev_lkcf_execute_task()
Date: Wed, 19 Mar 2025 14:29:00 +0800 [thread overview]
Message-ID: <cb712323-6511-4557-b5a5-0bc29a4dcb85@bytedance.com> (raw)
In-Reply-To: <20250312101131.1615777-1-armbru@redhat.com>
LGTM, thanks!
Reviewed-by: zhenwei pi <pizhenwei@bytedance.com>
On 3/12/25 18:11, Markus Armbruster wrote:
> 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>
> ---
> backends/cryptodev-lkcf.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
> index 41cf24b737..352c3e8958 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;
> }
next prev parent reply other threads:[~2025-03-19 6:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 10:11 [PATCH] cryptodev: Fix error handling in cryptodev_lkcf_execute_task() Markus Armbruster
2025-03-12 10:28 ` zhenwei pi
2025-03-12 12:02 ` Markus Armbruster
2025-03-14 8:34 ` zhenwei pi
2025-03-18 13:21 ` Markus Armbruster
2025-03-19 2:21 ` zhenwei pi
2025-03-19 5:12 ` Markus Armbruster
2025-03-19 6:29 ` zhenwei pi [this message]
2025-03-19 8:37 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cb712323-6511-4557-b5a5-0bc29a4dcb85@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).