lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20061009090122.GA6129@localhost>
Date:	Mon, 9 Oct 2006 18:01:22 +0900
From:	Akinobu Mita <akinobu.mita@...il.com>
To:	linux-kernel@...r.kernel.org,
	Herbert Xu <herbert@...dor.apana.org.au>,
	"David S. Miller" <davem@...emloft.net>
Subject: [PATCH 2/2] crypto: delete duplicated code

crypto_alloc_tfm() and crypto_alloc_base() are almost same.

Cc: Herbert Xu <herbert@...dor.apana.org.au>
Cc: "David S. Miller" <davem@...emloft.net>
Signed-off-by: Akinobu Mita <akinobu.mita@...il.com>

 crypto/api.c |   40 +++++++++-------------------------------
 1 file changed, 9 insertions(+), 31 deletions(-)

Index: work-fault-inject/crypto/api.c
===================================================================
--- work-fault-inject.orig/crypto/api.c	2006-10-09 15:09:00.000000000 +0900
+++ work-fault-inject/crypto/api.c	2006-10-09 15:09:04.000000000 +0900
@@ -362,7 +362,8 @@ out:
 }
 EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
 
-struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+static struct crypto_tfm *crypto_alloc_tfm_base(const char *name, u32 flags,
+						u32 type, u32 mask)
 {
 	struct crypto_tfm *tfm;
 	int err;
@@ -370,7 +371,7 @@ struct crypto_tfm *crypto_alloc_tfm(cons
 	for (;;) {
 		struct crypto_alg *alg;
 
-		alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
+		alg = crypto_alg_mod_lookup(name, type, mask);
 		if (IS_ERR(alg)) {
 			err = PTR_ERR(alg);
 			goto err;
@@ -395,6 +396,11 @@ err:
 	return ERR_PTR(err);
 }
 
+struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+{
+	return crypto_alloc_tfm_base(name, flags, 0, CRYPTO_ALG_ASYNC);
+}
+
 /*
  *	crypto_alloc_base - Locate algorithm and allocate transform
  *	@alg_name: Name of algorithm
@@ -416,35 +422,7 @@ err:
  */
 struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
 {
-	struct crypto_tfm *tfm;
-	int err;
-
-	for (;;) {
-		struct crypto_alg *alg;
-
-		alg = crypto_alg_mod_lookup(alg_name, type, mask);
-		if (IS_ERR(alg)) {
-			err = PTR_ERR(alg);
-			goto err;
-		}
-
-		tfm = __crypto_alloc_tfm(alg, 0);
-		if (!IS_ERR(tfm))
-			return tfm;
-
-		crypto_mod_put(alg);
-		err = PTR_ERR(tfm);
-
-err:
-		if (err != -EAGAIN)
-			break;
-		if (signal_pending(current)) {
-			err = -EINTR;
-			break;
-		}
-	}
-
-	return ERR_PTR(err);
+	return crypto_alloc_tfm_base(alg_name, 0, type, mask);
 }
 EXPORT_SYMBOL_GPL(crypto_alloc_base);
  
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ