Skip to contentSkip to conversation

crypto: asymmetric_keys - Fix error return code on failure

PATCH In review Wei Yongjun 3 participants 3 messages Feb 9, 2017 – Feb 10, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: asymmetric_keys - Fix error return code on failure

From: Wei Yongjun <[email protected]>

Fix to return error code -ENOMEM from the akcipher_request_alloc() error handling case instead of 0.

---
 crypto/asymmetric_keys/public_key.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
crypto/asymmetric_keys/public_key.c +6 -2
index 3a23274..3131bba 100644
@@ -184,8 +184,10 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
 		return PTR_ERR(tfm);
 
 	req = akcipher_request_alloc(tfm, GFP_KERNEL);
-	if (!req)
+	if (!req) {
+		ret = -ENOMEM;
 		goto error_free_tfm;
+	}
 
 	if (pkey->key_is_private)
 		ret = crypto_akcipher_set_priv_key(tfm,
@@ -268,8 +270,10 @@ int public_key_verify_signature(const struct public_key *pkey,
 		return PTR_ERR(tfm);
 
 	req = akcipher_request_alloc(tfm, GFP_KERNEL);
-	if (!req)
+	if (!req) {
+		ret = -ENOMEM;
 		goto error_free_tfm;
+	}
 
 	if (pkey->key_is_private)
 		ret = crypto_akcipher_set_priv_key(tfm,
maintainer
#1 lore raw

crypto/asymmetric_keys/public_key.c static int software_key_eds_op(struct kernel_pkey_params *params, · line 188

Quoted 9 lines · Wei Yongjun
crypto/asymmetric_keys/public_key.c +2 -1
@@ -184,8 +184,10 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
 		return PTR_ERR(tfm);
 
 	req = akcipher_request_alloc(tfm, GFP_KERNEL);
-	if (!req)
+	if (!req) {
+		ret = -ENOMEM;

Ummm... What should I apply your patch to?

crypto/asymmetric_keys/public_key.c int public_key_verify_signature(const struct public_key *pkey, · line 275

Quoted 13 lines
crypto/asymmetric_keys/public_key.c +3 -1
 		goto error_free_tfm;
+	}
 
 	if (pkey->key_is_private)
 		ret = crypto_akcipher_set_priv_key(tfm,
@@ -268,8 +270,10 @@ int public_key_verify_signature(const struct public_key *pkey,
 		return PTR_ERR(tfm);
 
 	req = akcipher_request_alloc(tfm, GFP_KERNEL);
-	if (!req)
+	if (!req) {
+		ret = -ENOMEM;
 		goto error_free_tfm;

This shouldn't be necessary. ret should already be -ENOMEM from initialisation of the variable at the top of the function.

David

#2 lore raw

Hi David,

Quoted 4 lines

crypto/asymmetric_keys/public_key.c static int software_key_eds_op(struct

Quoted 3 lines
crypto/asymmetric_keys/public_key.c +0 -0
@@ -184,8 +184,10 @@ static int software_key_eds_op(struct

kernel_pkey_params *params,

Quoted 8 lines

crypto/asymmetric_keys/public_key.c static int software_key_eds_op(struct kernel_pkey_params *params, · line 188

Quoted 6 lines
crypto/asymmetric_keys/public_key.c +2 -1
 		return PTR_ERR(tfm);
 
 	req = akcipher_request_alloc(tfm, GFP_KERNEL);
-	if (!req)
+	if (!req) {
+		ret = -ENOMEM;

Ummm... What should I apply your patch to?

This one introduced by patch " KEYS: Implement encrypt, decrypt and sign for software asymmetric key".

Quoted 10 lines

crypto/asymmetric_keys/public_key.c int public_key_verify_signature(const struct

Quoted 7 lines
crypto/asymmetric_keys/public_key.c +1 -0
 		goto error_free_tfm;
+	}
 
 	if (pkey->key_is_private)
 		ret = crypto_akcipher_set_priv_key(tfm,
@@ -268,8 +270,10 @@ int public_key_verify_signature(const struct

public_key *pkey,

Quoted 2 lines
crypto/asymmetric_keys/public_key.c +0 -0
 		return PTR_ERR(tfm);
 
Quoted 8 lines

crypto/asymmetric_keys/public_key.c static int software_key_eds_op(struct kernel_pkey_params *params, · line 189

Quoted 5 lines
crypto/asymmetric_keys/public_key.c +2 -1
 	req = akcipher_request_alloc(tfm, GFP_KERNEL);
-	if (!req)
+	if (!req) {
+		ret = -ENOMEM;
 		goto error_free_tfm;

This shouldn't be necessary. ret should already be -ENOMEM from initialisation of the variable at the top of the function.

Introduced by patch " KEYS: Provide software public key query function", ret have been overwritten to 0 after ret = software_key_determine_akcipher(...).

Regards,
Wei Yongjun