diff mbox

[v2] X.509: Fix error code in x509_cert_parse()

Message ID 20170529132622.6tapug7i7aqmvnqz@mwanda (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Dan Carpenter May 29, 2017, 1:26 p.m. UTC
We forgot to set the error code on this path so it could result in
returning NULL which leads to a NULL dereference.

Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2:  Style change

Sorry for the delay, I'm been out of office.

Comments

Herbert Xu June 10, 2017, 4:18 a.m. UTC | #1
On Mon, May 29, 2017 at 04:26:22PM +0300, Dan Carpenter wrote:
> We forgot to set the error code on this path so it could result in
> returning NULL which leads to a NULL dereference.
> 
> Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2:  Style change

Patch applied.  Thanks.
David Howells June 10, 2017, 6:14 a.m. UTC | #2
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> Patch applied.  Thanks.

Note that I've passed this on to James to pass on to Linus along with a bunch
of other patches.

David
diff mbox

Patch

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index c80765b211cf..dd03fead1ca3 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -102,6 +102,7 @@  struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 		}
 	}
 
+	ret = -ENOMEM;
 	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
 	if (!cert->pub->key)
 		goto error_decode;