[patch v2] pcrypt: handle crypto_get_attr_type() errors

2010-03-22 Thread Dan Carpenter
I was concerned about the error handling for crypto_get_attr_type() in
pcrypt_alloc_aead().  Steffen Klassert pointed out that we could simply 
avoid calling crypto_get_attr_type() if we passed the type and mask as a 
parameter.

Signed-off-by: Dan Carpenter 

diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index 8020124..e049388 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -315,13 +315,11 @@ out_free_inst:
goto out;
 }
 
-static struct crypto_instance *pcrypt_alloc_aead(struct rtattr **tb)
+static struct crypto_instance *pcrypt_alloc_aead(struct rtattr **tb,
+struct crypto_attr_type *algt)
 {
struct crypto_instance *inst;
struct crypto_alg *alg;
-   struct crypto_attr_type *algt;
-
-   algt = crypto_get_attr_type(tb);
 
alg = crypto_get_attr_alg(tb, algt->type,
  (algt->mask & CRYPTO_ALG_TYPE_MASK));
@@ -365,7 +363,7 @@ static struct crypto_instance *pcrypt_alloc(struct rtattr 
**tb)
 
switch (algt->type & algt->mask & CRYPTO_ALG_TYPE_MASK) {
case CRYPTO_ALG_TYPE_AEAD:
-   return pcrypt_alloc_aead(tb);
+   return pcrypt_alloc_aead(tb, algt);
}
 
return ERR_PTR(-EINVAL);
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v2] pcrypt: handle crypto_get_attr_type() errors

2010-03-22 Thread Steffen Klassert
On Mon, Mar 22, 2010 at 04:53:19PM +0300, Dan Carpenter wrote:
>  
> -static struct crypto_instance *pcrypt_alloc_aead(struct rtattr **tb)
> +static struct crypto_instance *pcrypt_alloc_aead(struct rtattr **tb,
> +  struct crypto_attr_type *algt)
>  {
>   struct crypto_instance *inst;
>   struct crypto_alg *alg;
> - struct crypto_attr_type *algt;
> -
> - algt = crypto_get_attr_type(tb);
>  
>   alg = crypto_get_attr_alg(tb, algt->type,
> (algt->mask & CRYPTO_ALG_TYPE_MASK));
> @@ -365,7 +363,7 @@ static struct crypto_instance *pcrypt_alloc(struct rtattr 
> **tb)
>  
>   switch (algt->type & algt->mask & CRYPTO_ALG_TYPE_MASK) {
>   case CRYPTO_ALG_TYPE_AEAD:
> - return pcrypt_alloc_aead(tb);
> + return pcrypt_alloc_aead(tb, algt);
>   }
>  

I thought about passing the type and mask values separately to
pcrypt_alloc_aead, like type and mask values are passed to
crypto_get_attr_alg. This is the usual way to do this in the
crypto layer.

Thanks,

Steffen
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html