KEYS: asymmetric: return ENOMEM if akcipher_request_alloc() fails
authorEric Biggers <ebiggers@google.com>
Wed, 9 Oct 2019 23:03:49 +0000 (16:03 -0700)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Thu, 12 Dec 2019 21:45:16 +0000 (23:45 +0200)
No error code was being set on this error path.

Cc: stable@vger.kernel.org
Fixes: ad4b1eb5fb33 ("KEYS: asym_tpm: Implement encryption operation [ver #2]")
Fixes: c08fed737126 ("KEYS: Implement encrypt, decrypt and sign for software asymmetric key [ver #2]")
Reviewed-by: James Morris <jamorris@linux.microsoft.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
crypto/asymmetric_keys/asym_tpm.c
crypto/asymmetric_keys/public_key.c

index d16d893bd1959ca7d69eab2b011faa13c8e410c9..378b18b9bc342a5aa9afb4efb8cf180f0a1edd76 100644 (file)
@@ -470,6 +470,7 @@ static int tpm_key_encrypt(struct tpm_key *tk,
        if (ret < 0)
                goto error_free_tfm;
 
+       ret = -ENOMEM;
        req = akcipher_request_alloc(tfm, GFP_KERNEL);
        if (!req)
                goto error_free_tfm;
index 364b9df9d631ff672a8fca0b74ecda0fb5b4ec11..d7f43d4ea925a0dcaa1fbce77dbef3b81fc4bc62 100644 (file)
@@ -184,6 +184,7 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
        if (IS_ERR(tfm))
                return PTR_ERR(tfm);
 
+       ret = -ENOMEM;
        req = akcipher_request_alloc(tfm, GFP_KERNEL);
        if (!req)
                goto error_free_tfm;