Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Stephan Mueller <smueller@chronox.de>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: Re: crypto: api - Change crypto_unregister_instance argument type
Date: Thu, 02 Apr 2015 16:54:03 +0200	[thread overview]
Message-ID: <2597941.K7IMfLeYM0@tauon> (raw)
In-Reply-To: <20150402143940.GA9947@gondor.apana.org.au>

Am Donnerstag, 2. April 2015, 22:39:40 schrieb Herbert Xu:

Hi Herbert,

>This patch makes crypto_unregister_instance take a crypto_instance
>instead of a crypto_alg.  This allows us to remove a duplicate
>CRYPTO_ALG_INSTANCE check in crypto_unregister_instance.
>
>Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
>diff --git a/crypto/algapi.c b/crypto/algapi.c
>index 0f1976e..f1d0307 100644
>--- a/crypto/algapi.c
>+++ b/crypto/algapi.c
>@@ -551,17 +551,13 @@ err:
> }
> EXPORT_SYMBOL_GPL(crypto_register_instance);
>
>-int crypto_unregister_instance(struct crypto_alg *alg)
>+int crypto_unregister_instance(struct crypto_instance *inst)
> {
>-	struct crypto_instance *inst = (void *)alg;
> 	LIST_HEAD(list);
>
>-	if (!(alg->cra_flags & CRYPTO_ALG_INSTANCE))
>-		return -EINVAL;
>-
> 	down_write(&crypto_alg_sem);
>
>-	crypto_remove_spawns(alg, &list, NULL);
>+	crypto_remove_spawns(&inst->alg, &list, NULL);
> 	crypto_remove_instance(inst, &list);
>
> 	up_write(&crypto_alg_sem);
>diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
>index c5148a3..eab2497 100644
>--- a/crypto/crypto_user.c
>+++ b/crypto/crypto_user.c
>@@ -316,7 +316,7 @@ static int crypto_del_alg(struct sk_buff *skb, struct
>nlmsghdr *nlh, if (atomic_read(&alg->cra_refcnt) != 1)
> 		return -EBUSY;
>
>-	return crypto_unregister_instance(alg);
>+	return crypto_unregister_instance((struct crypto_instance *)alg);

Instead of using type casts, isn't container_of() a cleaner way (and hopefully 
a safer way) of casting? 
> }
>
> static struct crypto_alg *crypto_user_skcipher_alg(const char *name, u32
>type, diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
>index 623a59c..0ecb768 100644
>--- a/include/crypto/algapi.h
>+++ b/include/crypto/algapi.h
>@@ -137,7 +137,7 @@ struct crypto_template *crypto_lookup_template(const char
>*name);
>
> int crypto_register_instance(struct crypto_template *tmpl,
> 			     struct crypto_instance *inst);
>-int crypto_unregister_instance(struct crypto_alg *alg);
>+int crypto_unregister_instance(struct crypto_instance *inst);
>
> int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
> 		      struct crypto_instance *inst, u32 mask);


Ciao
Stephan

  reply	other threads:[~2015-04-02 14:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 14:31 crypto: api - Fix races in crypto_unregister_instance Herbert Xu
2015-04-02 14:39 ` crypto: api - Change crypto_unregister_instance argument type Herbert Xu
2015-04-02 14:54   ` Stephan Mueller [this message]
2015-04-02 14:59     ` Herbert Xu
2015-04-02 15:13       ` Stephan Mueller
2015-04-02 15:15         ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2597941.K7IMfLeYM0@tauon \
    --to=smueller@chronox.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox