diff mbox series

crypto: sa2ul - Add check for crypto_aead_setkey

Message ID 20231107063152.529830-1-nichen@iscas.ac.cn (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show
Series crypto: sa2ul - Add check for crypto_aead_setkey | expand

Commit Message

Chen Ni Nov. 7, 2023, 6:31 a.m. UTC
Add check for crypto_aead_setkey() and return the error if it fails
in order to transfer the error.

Fixes: d2c8ac187fc9 ("crypto: sa2ul - Add AEAD algorithm support")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/crypto/sa2ul.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Herbert Xu Nov. 17, 2023, 10:29 a.m. UTC | #1
Chen Ni <nichen@iscas.ac.cn> wrote:
> Add check for crypto_aead_setkey() and return the error if it fails
> in order to transfer the error.
> 
> Fixes: d2c8ac187fc9 ("crypto: sa2ul - Add AEAD algorithm support")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
> drivers/crypto/sa2ul.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
> index 6846a8429574..6bac2382e261 100644
> --- a/drivers/crypto/sa2ul.c
> +++ b/drivers/crypto/sa2ul.c
> @@ -1806,6 +1806,7 @@ static int sa_aead_setkey(struct crypto_aead *authenc,
>        int cmdl_len;
>        struct sa_cmdl_cfg cfg;
>        int key_idx;
> +       int error;
> 
>        if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
>                return -EINVAL;
> @@ -1869,7 +1870,9 @@ static int sa_aead_setkey(struct crypto_aead *authenc,
>        crypto_aead_set_flags(ctx->fallback.aead,
>                              crypto_aead_get_flags(authenc) &
>                              CRYPTO_TFM_REQ_MASK);
> -       crypto_aead_setkey(ctx->fallback.aead, key, keylen);
> +       error = crypto_aead_setkey(ctx->fallback.aead, key, keylen);
> +       if (error)
> +               return error;

This should be

	return crypto_aead_setkey(ctx->fallback.aead, key, keylen);

Thanks,
diff mbox series

Patch

diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index 6846a8429574..6bac2382e261 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -1806,6 +1806,7 @@  static int sa_aead_setkey(struct crypto_aead *authenc,
 	int cmdl_len;
 	struct sa_cmdl_cfg cfg;
 	int key_idx;
+	int error;
 
 	if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
 		return -EINVAL;
@@ -1869,7 +1870,9 @@  static int sa_aead_setkey(struct crypto_aead *authenc,
 	crypto_aead_set_flags(ctx->fallback.aead,
 			      crypto_aead_get_flags(authenc) &
 			      CRYPTO_TFM_REQ_MASK);
-	crypto_aead_setkey(ctx->fallback.aead, key, keylen);
+	error = crypto_aead_setkey(ctx->fallback.aead, key, keylen);
+	if (error)
+		return error;
 
 	return 0;
 }