Browse Source

[CRYPTO] api: Read module pointer before freeing algorithm

The function crypto_mod_put first frees the algorithm and then drops
the reference to its module.  Unfortunately we read the module pointer
which after freeing the algorithm and that pointer sits inside the
object that we just freed.

So this patch reads the module pointer out before we free the object.

Thanks to Luca Tettamanti for reporting this.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Herbert Xu 18 years ago
parent
commit
da7cd59ab9
1 changed files with 3 additions and 1 deletions
  1. 3 1
      crypto/api.c

+ 3 - 1
crypto/api.c

@@ -48,8 +48,10 @@ EXPORT_SYMBOL_GPL(crypto_mod_get);
 
 
 void crypto_mod_put(struct crypto_alg *alg)
 void crypto_mod_put(struct crypto_alg *alg)
 {
 {
+	struct module *module = alg->cra_module;
+
 	crypto_alg_put(alg);
 	crypto_alg_put(alg);
-	module_put(alg->cra_module);
+	module_put(module);
 }
 }
 EXPORT_SYMBOL_GPL(crypto_mod_put);
 EXPORT_SYMBOL_GPL(crypto_mod_put);