summaryrefslogtreecommitdiff
path: root/crypto
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
commitf62d7f91afa21066404aae3031517c8c4310a9b6 (patch)
tree2ea050d56eccf00cad9a5eb4723728ca7f8e009c /crypto
parentc5acd9395d4158ed320b4d27aa6afe8faf093d94 (diff)
keys: asymmetric: fix error return code in software_key_query()
[ Upstream commit 6cbba1f9114a8134cff9138c79add15012fd52b9 ] Fix to return negative error code -ENOMEM from kmalloc() error handling case instead of 0, as done elsewhere in this function. Fixes: f1774cb8956a ("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')
-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 d7f43d4ea925..e5fae4e838c0 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)