* [PATCH -next] crypto: asymmetric_keys - Fix error return code on failure
@ 2017-02-09 15:57 Wei Yongjun
2017-02-09 16:57 ` David Howells
0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2017-02-09 15:57 UTC (permalink / raw)
To: David Howells, Herbert Xu; +Cc: Wei Yongjun, keyrings, linux-crypto
From: Wei Yongjun <weiyongjun1@huawei.com>
Fix to return error code -ENOMEM from the akcipher_request_alloc()
error handling case instead of 0.
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
crypto/asymmetric_keys/public_key.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index 3a23274..3131bba 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -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,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] crypto: asymmetric_keys - Fix error return code on failure
2017-02-09 15:57 [PATCH -next] crypto: asymmetric_keys - Fix error return code on failure Wei Yongjun
@ 2017-02-09 16:57 ` David Howells
2017-02-10 2:11 ` weiyongjun (A)
0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2017-02-09 16:57 UTC (permalink / raw)
To: Wei Yongjun; +Cc: dhowells, Herbert Xu, Wei Yongjun, keyrings, linux-crypto
Wei Yongjun <weiyj.lk@gmail.com> wrote:
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c
> @@ -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?
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH -next] crypto: asymmetric_keys - Fix error return code on failure
2017-02-09 16:57 ` David Howells
@ 2017-02-10 2:11 ` weiyongjun (A)
0 siblings, 0 replies; 3+ messages in thread
From: weiyongjun (A) @ 2017-02-10 2:11 UTC (permalink / raw)
To: David Howells, Wei Yongjun; +Cc: Herbert Xu, keyrings, linux-crypto
Hi David,
> > --- a/crypto/asymmetric_keys/public_key.c
> > +++ b/crypto/asymmetric_keys/public_key.c
> > @@ -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?
This one introduced by patch " KEYS: Implement encrypt, decrypt and sign for software asymmetric key".
>
> > 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.
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-10 2:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09 15:57 [PATCH -next] crypto: asymmetric_keys - Fix error return code on failure Wei Yongjun
2017-02-09 16:57 ` David Howells
2017-02-10 2:11 ` weiyongjun (A)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).