* Re: Possible BUG on net/ipv4/ipcomp.c, line 358 (fwd)
[not found] <Xine.LNX.4.64.0711070751530.27327@us.intercode.com.au>
@ 2007-11-07 1:11 ` Herbert Xu
2007-11-07 10:22 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Herbert Xu @ 2007-11-07 1:11 UTC (permalink / raw)
To: James Morris; +Cc: David S. Miller, netdev
On Wed, Nov 07, 2007 at 07:51:57AM +1100, James Morris wrote:
>
> ---------- Forwarded message ----------
> Date: Tue, 06 Nov 2007 14:53:30 +0100
> From: Vicenç <vbeltran@ac.upc.edu>
> To: jmorris@intercode.com.au
> Subject: Possible BUG on net/ipv4/ipcomp.c, line 358
>
> Hi James,
>
> I think there is a bug on net/ipv4/ipcomp.c line 358. The trivial patch that
> should fix it is:
Thanks for the report! The same bug exists in IPv6 too and
this patch should fix both.
[IPSEC]: Fix crypto_alloc_comp error checking
The function crypto_alloc_comp returns an errno instead of NULL
to indicate error. So it needs to be tested with IS_ERR.
This is based on a patch by Vicenç Beltran Querol.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
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
--
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index ca1b5fd..2c44a94 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <asm/semaphore.h>
#include <linux/crypto.h>
+#include <linux/err.h>
#include <linux/pfkeyv2.h>
#include <linux/percpu.h>
#include <linux/smp.h>
@@ -344,7 +345,7 @@ static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name)
for_each_possible_cpu(cpu) {
struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
CRYPTO_ALG_ASYNC);
- if (!tfm)
+ if (IS_ERR(tfm))
goto error;
*per_cpu_ptr(tfms, cpu) = tfm;
}
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 85eb479..0cd4056 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -36,6 +36,7 @@
#include <net/ipcomp.h>
#include <asm/semaphore.h>
#include <linux/crypto.h>
+#include <linux/err.h>
#include <linux/pfkeyv2.h>
#include <linux/random.h>
#include <linux/percpu.h>
@@ -358,7 +359,7 @@ static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name)
for_each_possible_cpu(cpu) {
struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
CRYPTO_ALG_ASYNC);
- if (!tfm)
+ if (IS_ERR(tfm))
goto error;
*per_cpu_ptr(tfms, cpu) = tfm;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread