2007-12-17 10:31:18

by Herbert Xu

[permalink] [raw]
Subject: [PATCH 3/8] [CRYPTO] aead/skcipher: Fix larval leak

[CRYPTO] aead/skcipher: Fix larval leak

When we get a non-larval from crypto_larval_lookup we need to drop its
reference count before leaving the default geniv construction.

Signed-off-by: Herbert Xu <[email protected]>
---

crypto/ablkcipher.c | 5 +++--
crypto/aead.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
index 83cfed7..3bcb099 100644
--- a/crypto/ablkcipher.c
+++ b/crypto/ablkcipher.c
@@ -209,7 +209,7 @@ static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask)

err = -EAGAIN;
if (!crypto_is_larval(larval))
- goto out;
+ goto drop_larval;

ptype.attr.rta_len = sizeof(ptype);
ptype.attr.rta_type = CRYPTOA_TYPE;
@@ -256,8 +256,9 @@ static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask)
put_tmpl:
crypto_tmpl_put(tmpl);
kill_larval:
- crypto_mod_put(larval);
crypto_larval_kill(larval);
+drop_larval:
+ crypto_mod_put(larval);
out:
crypto_mod_put(alg);
return err;
diff --git a/crypto/aead.c b/crypto/aead.c
index 77694ad..058ca74 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -359,7 +359,7 @@ static int crypto_nivaead_default(struct crypto_alg *alg, u32 type, u32 mask)

err = -EAGAIN;
if (!crypto_is_larval(larval))
- goto out;
+ goto drop_larval;

ptype.attr.rta_len = sizeof(ptype);
ptype.attr.rta_type = CRYPTOA_TYPE;
@@ -399,8 +399,9 @@ static int crypto_nivaead_default(struct crypto_alg *alg, u32 type, u32 mask)
put_tmpl:
crypto_tmpl_put(tmpl);
kill_larval:
- crypto_mod_put(larval);
crypto_larval_kill(larval);
+drop_larval:
+ crypto_mod_put(larval);
out:
crypto_mod_put(alg);
return err;