Re: [PATCH] crypto: scompress - Fix scratch allocation failure handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 15 Mar 2025 at 13:37, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> If the scratch allocation fails, all subsequent allocations will
> silently succeed without actually allocating anything.  Fix this
> by only incrementing users when the allocation succeeds.
>
> Fixes: 6a8487a1f29f ("crypto: scompress - defer allocation of scratch buffer to first use")
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

Acked-by: Ard Biesheuvel <ardb@xxxxxxxxxx>

> ---
>  crypto/scompress.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/crypto/scompress.c b/crypto/scompress.c
> index dc239ea8a46c..57bb7353d767 100644
> --- a/crypto/scompress.c
> +++ b/crypto/scompress.c
> @@ -159,8 +159,12 @@ static int crypto_scomp_init_tfm(struct crypto_tfm *tfm)
>                 if (ret)
>                         goto unlock;
>         }
> -       if (!scomp_scratch_users++)
> +       if (!scomp_scratch_users) {
>                 ret = crypto_scomp_alloc_scratches();
> +               if (ret)
> +                       goto unlock;
> +               scomp_scratch_users++;
> +       }
>  unlock:
>         mutex_unlock(&scomp_lock);
>
> --
> 2.39.5
>
> --
> Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux