diff options
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r-- | crypto/algapi.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index c91530021e9c..f7d2185b2c8f 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -377,7 +377,8 @@ void crypto_drop_spawn(struct crypto_spawn *spawn) | |||
377 | } | 377 | } |
378 | EXPORT_SYMBOL_GPL(crypto_drop_spawn); | 378 | EXPORT_SYMBOL_GPL(crypto_drop_spawn); |
379 | 379 | ||
380 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) | 380 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, |
381 | u32 mask) | ||
381 | { | 382 | { |
382 | struct crypto_alg *alg; | 383 | struct crypto_alg *alg; |
383 | struct crypto_alg *alg2; | 384 | struct crypto_alg *alg2; |
@@ -396,10 +397,18 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) | |||
396 | return ERR_PTR(-EAGAIN); | 397 | return ERR_PTR(-EAGAIN); |
397 | } | 398 | } |
398 | 399 | ||
399 | tfm = __crypto_alloc_tfm(alg, 0); | 400 | tfm = ERR_PTR(-EINVAL); |
401 | if (unlikely((alg->cra_flags ^ type) & mask)) | ||
402 | goto out_put_alg; | ||
403 | |||
404 | tfm = __crypto_alloc_tfm(alg, type, mask); | ||
400 | if (IS_ERR(tfm)) | 405 | if (IS_ERR(tfm)) |
401 | crypto_mod_put(alg); | 406 | goto out_put_alg; |
407 | |||
408 | return tfm; | ||
402 | 409 | ||
410 | out_put_alg: | ||
411 | crypto_mod_put(alg); | ||
403 | return tfm; | 412 | return tfm; |
404 | } | 413 | } |
405 | EXPORT_SYMBOL_GPL(crypto_spawn_tfm); | 414 | EXPORT_SYMBOL_GPL(crypto_spawn_tfm); |