Commit 6c7ad737 authored by Herbert Xu's avatar Herbert Xu Committed by Greg Kroah-Hartman

Fix crypto_alloc_comp() error checking.

[IPSEC]: Fix crypto_alloc_comp error checking

[ Upstream commit: 4999f362 ]

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: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3040f069
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <asm/scatterlist.h> #include <asm/scatterlist.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h>
#include <linux/pfkeyv2.h> #include <linux/pfkeyv2.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/smp.h> #include <linux/smp.h>
...@@ -355,7 +356,7 @@ static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name) ...@@ -355,7 +356,7 @@ static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name)
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
CRYPTO_ALG_ASYNC); CRYPTO_ALG_ASYNC);
if (!tfm) if (IS_ERR(tfm))
goto error; goto error;
*per_cpu_ptr(tfms, cpu) = tfm; *per_cpu_ptr(tfms, cpu) = tfm;
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <asm/scatterlist.h> #include <asm/scatterlist.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h>
#include <linux/pfkeyv2.h> #include <linux/pfkeyv2.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/percpu.h> #include <linux/percpu.h>
...@@ -366,7 +367,7 @@ static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name) ...@@ -366,7 +367,7 @@ static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name)
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
CRYPTO_ALG_ASYNC); CRYPTO_ALG_ASYNC);
if (!tfm) if (IS_ERR(tfm))
goto error; goto error;
*per_cpu_ptr(tfms, cpu) = tfm; *per_cpu_ptr(tfms, cpu) = tfm;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment