Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+14 -5
+10 -3
crypto/api.c
··· 386 386 } 387 387 EXPORT_SYMBOL_GPL(crypto_shoot_alg); 388 388 389 - struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, 390 - u32 mask) 389 + struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type, 390 + u32 mask, gfp_t gfp) 391 391 { 392 392 struct crypto_tfm *tfm = NULL; 393 393 unsigned int tfm_size; 394 394 int err = -ENOMEM; 395 395 396 396 tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask); 397 - tfm = kzalloc(tfm_size, GFP_KERNEL); 397 + tfm = kzalloc(tfm_size, gfp); 398 398 if (tfm == NULL) 399 399 goto out_err; 400 400 ··· 415 415 tfm = ERR_PTR(err); 416 416 out: 417 417 return tfm; 418 + } 419 + EXPORT_SYMBOL_GPL(__crypto_alloc_tfmgfp); 420 + 421 + struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, 422 + u32 mask) 423 + { 424 + return __crypto_alloc_tfmgfp(alg, type, mask, GFP_KERNEL); 418 425 } 419 426 EXPORT_SYMBOL_GPL(__crypto_alloc_tfm); 420 427
+2 -2
crypto/cipher.c
··· 101 101 if (alg->cra_init) 102 102 return ERR_PTR(-ENOSYS); 103 103 104 - ntfm = __crypto_alloc_tfm(alg, CRYPTO_ALG_TYPE_CIPHER, 105 - CRYPTO_ALG_TYPE_MASK); 104 + ntfm = __crypto_alloc_tfmgfp(alg, CRYPTO_ALG_TYPE_CIPHER, 105 + CRYPTO_ALG_TYPE_MASK, GFP_ATOMIC); 106 106 if (IS_ERR(ntfm)) 107 107 return ERR_CAST(ntfm); 108 108
+2
crypto/internal.h
··· 102 102 struct crypto_alg *nalg); 103 103 void crypto_remove_final(struct list_head *list); 104 104 void crypto_shoot_alg(struct crypto_alg *alg); 105 + struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type, 106 + u32 mask, gfp_t gfp); 105 107 struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, 106 108 u32 mask); 107 109 void *crypto_create_tfm_node(struct crypto_alg *alg,