lkml.org 
[lkml]   [2008]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] crypto: Correct kzalloc error test
Date
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


\
 
 \ /
  Last update: 2008-04-29 16:11    [W:0.270 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site