keys: asymmetric: fix error return code in software_key_query()
authorWei Yongjun <weiyongjun1@huawei.com>
Wed, 15 Jul 2020 22:28:38 +0000 (23:28 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 15 Jul 2020 22:49:04 +0000 (15:49 -0700)
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>
crypto/asymmetric_keys/public_key.c

index d7f43d4ea925a0dcaa1fbce77dbef3b81fc4bc62..e5fae4e838c067d2fb27996ee5446e6879638bcb 100644 (file)
@@ -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)