crypto: api - Add __crypto_alloc_tfmgfp

JIRA: https://redhat.atlassian.net/browse/RHEL-142637
Upstream Status: net.git commit fa3b3565f3ac5a468e3efebca00e10db5db3d6bb

commit fa3b3565f3ac5a468e3efebca00e10db5db3d6bb
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Thu Jun 15 17:00:51 2023 +0800

    crypto: api - Add __crypto_alloc_tfmgfp

    Use it straight away in crypto_clone_cipher(), as that is not meant to
    sleep.

    Fixes: 51d8d6d0f4be ("crypto: cipher - Add crypto_clone_cipher")
    Signed-off-by: Dmitry Safonov <dima@arista.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
This commit is contained in:
Davide Caratti
2026-07-06 23:21:04 +02:00
parent 70248523f2
commit c0cfafcd5e
3 changed files with 14 additions and 5 deletions
+10 -3
View File
@@ -395,15 +395,15 @@ void crypto_shoot_alg(struct crypto_alg *alg)
}
EXPORT_SYMBOL_GPL(crypto_shoot_alg);
struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
u32 mask)
struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type,
u32 mask, gfp_t gfp)
{
struct crypto_tfm *tfm = NULL;
unsigned int tfm_size;
int err = -ENOMEM;
tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask);
tfm = kzalloc(tfm_size, GFP_KERNEL);
tfm = kzalloc(tfm_size, gfp);
if (tfm == NULL)
goto out_err;
@@ -430,6 +430,13 @@ out_err:
out:
return tfm;
}
EXPORT_SYMBOL_GPL(__crypto_alloc_tfmgfp);
struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
u32 mask)
{
return __crypto_alloc_tfmgfp(alg, type, mask, GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
/*
+2 -2
View File
@@ -101,8 +101,8 @@ struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher)
if (alg->cra_init)
return ERR_PTR(-ENOSYS);
ntfm = __crypto_alloc_tfm(alg, CRYPTO_ALG_TYPE_CIPHER,
CRYPTO_ALG_TYPE_MASK);
ntfm = __crypto_alloc_tfmgfp(alg, CRYPTO_ALG_TYPE_CIPHER,
CRYPTO_ALG_TYPE_MASK, GFP_ATOMIC);
if (IS_ERR(ntfm))
return ERR_CAST(ntfm);
+2
View File
@@ -100,6 +100,8 @@ void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list,
struct crypto_alg *nalg);
void crypto_remove_final(struct list_head *list);
void crypto_shoot_alg(struct crypto_alg *alg);
struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type,
u32 mask, gfp_t gfp);
struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
u32 mask);
void *crypto_create_tfm_node(struct crypto_alg *alg,