diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-12-17 00:05:58 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-02-06 23:21:01 +0100 |
commit | 2e306ee016fd4750289e65c3b1856db569f1f3f2 (patch) | |
tree | 53ace6081967c640f052d53397250657af855c25 /crypto/algapi.c | |
parent | [CRYPTO] api: Remove deprecated interface (diff) | |
download | linux-2e306ee016fd4750289e65c3b1856db569f1f3f2.tar.xz linux-2e306ee016fd4750289e65c3b1856db569f1f3f2.zip |
[CRYPTO] api: Add type-safe spawns
This patch allows spawns of specific types (e.g., cipher) to be allocated.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r-- | crypto/algapi.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 69eb504721a4..0f1abca1b98c 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -377,7 +377,8 @@ void crypto_drop_spawn(struct crypto_spawn *spawn) } EXPORT_SYMBOL_GPL(crypto_drop_spawn); -struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) +struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, + u32 mask) { struct crypto_alg *alg; struct crypto_alg *alg2; @@ -396,10 +397,18 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) return ERR_PTR(-EAGAIN); } + tfm = ERR_PTR(-EINVAL); + if (unlikely((alg->cra_flags ^ type) & mask)) + goto out_put_alg; + tfm = __crypto_alloc_tfm(alg); if (IS_ERR(tfm)) - crypto_mod_put(alg); + goto out_put_alg; + + return tfm; +out_put_alg: + crypto_mod_put(alg); return tfm; } EXPORT_SYMBOL_GPL(crypto_spawn_tfm); |