X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=crypto%2Fapi.c;h=959c4e5f264f42ed831720149b3627d9a9e6300c;hb=720a845911097cea1394fe7abb2c9efa76e32715;hp=2d8d828c0ca2c5147285a865ee67754d08ff5105;hpb=fbdae9f3e7fb57c07cb0d973f113eb25da2e8ff2;p=linux-2.6 diff --git a/crypto/api.c b/crypto/api.c index 2d8d828c0c..959c4e5f26 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -13,6 +13,8 @@ * any later version. * */ + +#include #include #include #include @@ -64,7 +66,8 @@ static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name) static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags) { - tfm->crt_flags = 0; + tfm->crt_flags = flags & CRYPTO_TFM_REQ_MASK; + flags &= ~CRYPTO_TFM_REQ_MASK; switch (crypto_tfm_alg_type(tfm)) { case CRYPTO_ALG_TYPE_CIPHER: @@ -189,8 +192,14 @@ out: void crypto_free_tfm(struct crypto_tfm *tfm) { - struct crypto_alg *alg = tfm->__crt_alg; - int size = sizeof(*tfm) + alg->cra_ctxsize; + struct crypto_alg *alg; + int size; + + if (unlikely(!tfm)) + return; + + alg = tfm->__crt_alg; + size = sizeof(*tfm) + alg->cra_ctxsize; crypto_exit_ops(tfm); crypto_alg_put(alg);