2021-05-19 19:58:55

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next] crypto: qce - Fix some error handling path

Fix to return negative error code from the error handling
cases instead of 0.

Fixes: 9363efb4181c ("crypto: qce - Add support for AEAD algorithms")
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/crypto/qce/aead.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qce/aead.c b/drivers/crypto/qce/aead.c
index 6d06a19b48e4..d47f4171ad83 100644
--- a/drivers/crypto/qce/aead.c
+++ b/drivers/crypto/qce/aead.c
@@ -280,8 +280,10 @@ qce_aead_ccm_prepare_buf_assoclen(struct aead_request *req)

if (diff_dst) {
sg = qce_aead_prepare_dst_buf(req);
- if (IS_ERR(sg))
+ if (IS_ERR(sg)) {
+ ret = PTR_ERR(sg);
goto err_free;
+ }
} else {
if (IS_ENCRYPT(rctx->flags))
rctx->dst_nents = rctx->src_nents + 1;
@@ -448,13 +450,17 @@ qce_aead_async_req_handle(struct crypto_async_request *async_req)
if (ret)
return ret;
dst_nents = dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst);
- if (dst_nents < 0)
+ if (dst_nents < 0) {
+ ret = dst_nents;
goto error_free;
+ }

if (diff_dst) {
src_nents = dma_map_sg(qce->dev, rctx->src_sg, rctx->src_nents, dir_src);
- if (src_nents < 0)
+ if (src_nents < 0) {
+ ret = src_nents;
goto error_unmap_dst;
+ }
} else {
if (IS_CCM(rctx->flags) && IS_DECRYPT(rctx->flags))
src_nents = dst_nents;



2021-05-28 06:24:17

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH -next] crypto: qce - Fix some error handling path

On Wed, May 19, 2021 at 02:16:50PM +0000, Wei Yongjun wrote:
>
> @@ -448,13 +450,17 @@ qce_aead_async_req_handle(struct crypto_async_request *async_req)
> if (ret)
> return ret;

Shouldn't this return do the error_free too?

> dst_nents = dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst);
> - if (dst_nents < 0)
> + if (dst_nents < 0) {
> + ret = dst_nents;
> goto error_free;
> + }
>
> if (diff_dst) {
> src_nents = dma_map_sg(qce->dev, rctx->src_sg, rctx->src_nents, dir_src);
> - if (src_nents < 0)
> + if (src_nents < 0) {
> + ret = src_nents;
> goto error_unmap_dst;
> + }
> } else {
> if (IS_CCM(rctx->flags) && IS_DECRYPT(rctx->flags))
> src_nents = dst_nents;

If so please send a follow-up patch.

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2021-05-28 07:43:09

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH -next] crypto: qce - Fix some error handling path

On Wed, May 19, 2021 at 02:16:50PM +0000, Wei Yongjun wrote:
> Fix to return negative error code from the error handling
> cases instead of 0.
>
> Fixes: 9363efb4181c ("crypto: qce - Add support for AEAD algorithms")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> drivers/crypto/qce/aead.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt