X.509: Fix error code in x509_cert_parse()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 29 May 2017 13:26:22 +0000 (16:26 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 10 Jun 2017 04:04:32 +0000 (12:04 +0800)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/asymmetric_keys/x509_cert_parser.c

index c80765b211cf0fae7a91c35494dc9ed45247eafe..dd03fead1ca358fc4f21cdb0c5c65b9896a39b38 100644 (file)
@@ -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;