X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=crypto%2Falgapi.c;h=f7d2185b2c8fbac94cf6f6736b5f1a965f224bb9;hb=39732acd968a007036ff3c504f1e6748024ef548;hp=c91530021e9ce6744b1382950eb9fed3d258d119;hpb=1ab9dd0902df4f4ff56fbf672220549090ab28ba;p=linux-2.6-omap-h63xx.git diff --git a/crypto/algapi.c b/crypto/algapi.c index c91530021e9..f7d2185b2c8 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 = __crypto_alloc_tfm(alg, 0); + tfm = ERR_PTR(-EINVAL); + if (unlikely((alg->cra_flags ^ type) & mask)) + goto out_put_alg; + + tfm = __crypto_alloc_tfm(alg, type, mask); 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);