2009-01-30 20:09:42

by Adrian-Ken Rueegsegger

[permalink] [raw]
Subject: [PATCH] crypto: shash - fix module refcount

Module reference counting for shash is incorrect: when
a new shash transformation is created the refcount is not
increased as it should.

Signed-off-by: Adrian-Ken Rueegsegger <[email protected]>
---
crypto/shash.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/crypto/shash.c b/crypto/shash.c
index c9df367..d5a2b61 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -388,10 +388,15 @@ static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm)
struct shash_desc *desc = crypto_tfm_ctx(tfm);
struct crypto_shash *shash;

+ if (!crypto_mod_get(calg))
+ return -EAGAIN;
+
shash = __crypto_shash_cast(crypto_create_tfm(
calg, &crypto_shash_type));
- if (IS_ERR(shash))
+ if (IS_ERR(shash)) {
+ crypto_mod_put(calg);
return PTR_ERR(shash);
+ }

desc->tfm = shash;
tfm->exit = crypto_exit_shash_ops_compat;
--
1.5.2.5



2009-02-05 05:20:06

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: shash - fix module refcount

On Fri, Jan 30, 2009 at 09:09:39PM +0100, Adrian-Ken Rueegsegger wrote:
> Module reference counting for shash is incorrect: when
> a new shash transformation is created the refcount is not
> increased as it should.
>
> Signed-off-by: Adrian-Ken Rueegsegger <[email protected]>

Applied to crypto-2.6. Thanks Adrian!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt