mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: Correct kzalloc error test
@ 2008-04-29 13:38 Julia Lawall
  2008-04-29 14:07 ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2008-04-29 13:38 UTC (permalink / raw)
  To: herbert, davem, linux-crypto, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Normally, kzalloc returns NULL or a valid pointer value, not a value to be
tested using IS_ERR.

Signed-off-by: Julia Lawall <julia@diku.dk>
---
diff -u -p  a/crypto/cryptd.c b/crypto/cryptd.c
--- a/crypto/cryptd.c	2008-04-16 13:27:56.000000000 +0200
+++ b/crypto/cryptd.c	2008-04-29 15:29:54.000000000 +0200
@@ -190,7 +190,7 @@ static struct crypto_instance *cryptd_al
 	int err;

 	inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
-	if (IS_ERR(inst))
+	if (!inst)
 		goto out;

 	err = -ENAMETOOLONG;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: Correct kzalloc error test
  2008-04-29 13:38 [PATCH] crypto: Correct kzalloc error test Julia Lawall
@ 2008-04-29 14:07 ` Herbert Xu
  2008-04-29 14:18   ` [revised PATCH] " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2008-04-29 14:07 UTC (permalink / raw)
  To: Julia Lawall; +Cc: herbert, davem, linux-crypto, linux-kernel, kernel-janitors

Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Normally, kzalloc returns NULL or a valid pointer value, not a value to be
> tested using IS_ERR.

Ouch :)

> diff -u -p  a/crypto/cryptd.c b/crypto/cryptd.c
> --- a/crypto/cryptd.c   2008-04-16 13:27:56.000000000 +0200
> +++ b/crypto/cryptd.c   2008-04-29 15:29:54.000000000 +0200
> @@ -190,7 +190,7 @@ static struct crypto_instance *cryptd_al
>        int err;
> 
>        inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
> -       if (IS_ERR(inst))
> +       if (!inst)
>                goto out;

However, this function is expected to return an ERR_PTR so you'll
need set it to ENOMEM first.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [revised PATCH] crypto: Correct kzalloc error test
  2008-04-29 14:07 ` Herbert Xu
@ 2008-04-29 14:18   ` Julia Lawall
  2008-04-29 16:27     ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2008-04-29 14:18 UTC (permalink / raw)
  To: Herbert Xu; +Cc: davem, linux-crypto, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Normally, kzalloc returns NULL or a valid pointer value, not a value to be
tested using IS_ERR.

Signed-off-by: Julia Lawall <julia@diku.dk>
---
diff -u -p  a/crypto/cryptd.c b/crypto/cryptd.c
--- a/crypto/cryptd.c	2008-04-16 13:27:56.000000000 +0200
+++ b/crypto/cryptd.c	2008-04-29 16:13:10.000000000 +0200
@@ -190,8 +190,10 @@ static struct crypto_instance *cryptd_al
 	int err;

 	inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
-	if (IS_ERR(inst))
+	if (!inst) {
+		inst = ERR_PTR(-ENOMEM);
 		goto out;
+	}

 	err = -ENAMETOOLONG;
 	if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [revised PATCH] crypto: Correct kzalloc error test
  2008-04-29 14:18   ` [revised PATCH] " Julia Lawall
@ 2008-04-29 16:27     ` Herbert Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2008-04-29 16:27 UTC (permalink / raw)
  To: Julia Lawall; +Cc: davem, linux-crypto, linux-kernel, kernel-janitors

On Tue, Apr 29, 2008 at 04:18:08PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Normally, kzalloc returns NULL or a valid pointer value, not a value to be
> tested using IS_ERR.
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Patch applied.  Thanks Julia!
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-29 16:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-29 13:38 [PATCH] crypto: Correct kzalloc error test Julia Lawall
2008-04-29 14:07 ` Herbert Xu
2008-04-29 14:18   ` [revised PATCH] " Julia Lawall
2008-04-29 16:27     ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®