summaryrefslogtreecommitdiff
path: root/crypto/asymmetric_keys/public_key.c
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2020-07-15 23:28:38 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-07-22 09:33:04 +0200
commit0f6c859f12a81750654641faf064a9faa8cf58ac (patch)
treec8cdfbbe06ec9ffe725f74002aa1bf5d121e0cef /crypto/asymmetric_keys/public_key.c
parentde09f0f762f50cb3b0c73b87c303f327aea0aab7 (diff)
downloadlinux-crypto-0f6c859f12a81750654641faf064a9faa8cf58ac.tar.gz
linux-crypto-0f6c859f12a81750654641faf064a9faa8cf58ac.zip
keys: asymmetric: fix error return code in software_key_query()
[ Upstream commit a95aa5c85186df292b00edeb49e2b2cb05d4b4dc ] Fix to return negative error code -ENOMEM from kmalloc() error handling case instead of 0, as done elsewhere in this function. Fixes: 1bef742086ae ("X.509: parse public key parameters from x509 for akcipher") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'crypto/asymmetric_keys/public_key.c')
-rw-r--r--crypto/asymmetric_keys/public_key.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index d7f43d4e..e5fae4e8 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -119,6 +119,7 @@ static int software_key_query(const struct kernel_pkey_params *params,
if (IS_ERR(tfm))
return PTR_ERR(tfm);
+ ret = -ENOMEM;
key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen,
GFP_KERNEL);
if (!key)