Skip to content

Commit 1c89dfe

Browse files
author
Markus Armbruster
committed
cryptodev: Fix error handling in cryptodev_lkcf_execute_task()
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 <[email protected]> Message-ID: <[email protected]> Reviewed-by: zhenwei pi <[email protected]>
1 parent 1dae461 commit 1c89dfe

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

backends/cryptodev-lkcf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTask *task)
330330
cryptodev_lkcf_set_op_desc(&session->akcipher_opts, op_desc,
331331
sizeof(op_desc), &local_error) != 0) {
332332
error_report_err(local_error);
333+
status = -VIRTIO_CRYPTO_ERR;
334+
goto out;
333335
} else {
334336
key_id = add_key(KCTL_KEY_TYPE_PKEY, "lkcf-backend-priv-key",
335337
p8info, p8info_len, KCTL_KEY_RING);
@@ -346,6 +348,7 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTask *task)
346348
session->key, session->keylen,
347349
&local_error);
348350
if (!akcipher) {
351+
error_report_err(local_error);
349352
status = -VIRTIO_CRYPTO_ERR;
350353
goto out;
351354
}

0 commit comments

Comments
 (0)