Re: [PATCH v2 20/30] crypto: sa2ul - handle transform initialization failures

From: T, Pratham

Date: Wed Nov 18 2026 - 04:26:22 EST


On 04/11/2026 11:14, Chawdhry, Manorit wrote:
> Stop initialization when security-context or fallback allocation fails,
> and propagate hash setup errors instead of exposing a partial transform.
>
> Unwind acquired fallback transforms and security contexts in reverse
> order. Release the hash context on fallback allocation failure, and use
> the hash teardown path when command-label setup fails.
>
> Fixes: 7694b6ca649f ("crypto: sa2ul - Add crypto driver")
> Fixes: 2dc53d004745 ("crypto: sa2ul - add sha1/sha256/sha512 support")
> Fixes: d2c8ac187fc9 ("crypto: sa2ul - Add AEAD algorithm support")
> Signed-off-by: Manorit Chawdhry <m-chawdhry@xxxxxx>
> ---

[...]

> @@ -1407,7 +1410,9 @@ static int sa_sha_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base)
> if (IS_ERR(ctx->fallback.ahash)) {
> dev_err(ctx->dev_data->dev,
> "Could not load fallback driver\n");
> - return PTR_ERR(ctx->fallback.ahash);
> + ret = PTR_ERR(ctx->fallback.ahash);
> + ctx->fallback.ahash = NULL;
> + goto err_free_ctx;
> }
> }
>
> @@ -1420,8 +1425,14 @@ static int sa_sha_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base)
> crypto_ahash_reqsize(ctx->fallback.ahash));
>
> return 0;
> +
> +err_free_ctx:
> + sa_free_ctx_info(&ctx->enc, data);
> + return ret;
> }
>
> +static void sa_sha_cra_exit(struct crypto_tfm *tfm);
> +

The function definition can be moved here instead of a forward declaration.

--
Regards
T Pratham <t-pratham@xxxxxx>