* [PATCH] crypto: hisilicon - Fix return value check in hisi_zip_acompress()
@ 2019-09-16 6:38 Yunfeng Ye
2019-09-19 6:12 ` Zhou Wang
2019-09-20 13:00 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Yunfeng Ye @ 2019-09-16 6:38 UTC (permalink / raw)
To: wangzhou1, herbert, davem; +Cc: linux-crypto, linux-kernel
The return valude of add_comp_head() is int, but @head_size is size_t,
which is a unsigned type.
size_t head_size;
...
if (head_size < 0) // it will never work
return -ENOMEM
Modify the type of @head_size to int, then change the type to size_t
when invoke hisi_zip_create_req() as a parameter.
Fixes: 62c455ca853e ("crypto: hisilicon - add HiSilicon ZIP accelerator support")
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
drivers/crypto/hisilicon/zip/zip_crypto.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c
index 5a3f84d..5902354 100644
--- a/drivers/crypto/hisilicon/zip/zip_crypto.c
+++ b/drivers/crypto/hisilicon/zip/zip_crypto.c
@@ -559,7 +559,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req)
struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm);
struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP];
struct hisi_zip_req *req;
- size_t head_size;
+ int head_size;
int ret;
/* let's output compression head now */
@@ -567,7 +567,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req)
if (head_size < 0)
return -ENOMEM;
- req = hisi_zip_create_req(acomp_req, qp_ctx, head_size, true);
+ req = hisi_zip_create_req(acomp_req, qp_ctx, (size_t)head_size, true);
if (IS_ERR(req))
return PTR_ERR(req);
--
2.7.4.huawei.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: hisilicon - Fix return value check in hisi_zip_acompress()
2019-09-16 6:38 [PATCH] crypto: hisilicon - Fix return value check in hisi_zip_acompress() Yunfeng Ye
@ 2019-09-19 6:12 ` Zhou Wang
2019-09-20 13:00 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Zhou Wang @ 2019-09-19 6:12 UTC (permalink / raw)
To: Yunfeng Ye, herbert, davem; +Cc: linux-crypto, linux-kernel
On 2019/9/16 14:38, Yunfeng Ye wrote:
> The return valude of add_comp_head() is int, but @head_size is size_t,
> which is a unsigned type.
>
> size_t head_size;
> ...
> if (head_size < 0) // it will never work
> return -ENOMEM
>
> Modify the type of @head_size to int, then change the type to size_t
> when invoke hisi_zip_create_req() as a parameter.
Acked-by: Zhou Wang <wangzhou1@hisilicon.com>
This is a bug, thinks for your fix!
Best,
Zhou
>
> Fixes: 62c455ca853e ("crypto: hisilicon - add HiSilicon ZIP accelerator support")
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> ---
> drivers/crypto/hisilicon/zip/zip_crypto.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c
> index 5a3f84d..5902354 100644
> --- a/drivers/crypto/hisilicon/zip/zip_crypto.c
> +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c
> @@ -559,7 +559,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req)
> struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm);
> struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP];
> struct hisi_zip_req *req;
> - size_t head_size;
> + int head_size;
> int ret;
>
> /* let's output compression head now */
> @@ -567,7 +567,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req)
> if (head_size < 0)
> return -ENOMEM;
>
> - req = hisi_zip_create_req(acomp_req, qp_ctx, head_size, true);
> + req = hisi_zip_create_req(acomp_req, qp_ctx, (size_t)head_size, true);
> if (IS_ERR(req))
> return PTR_ERR(req);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: hisilicon - Fix return value check in hisi_zip_acompress()
2019-09-16 6:38 [PATCH] crypto: hisilicon - Fix return value check in hisi_zip_acompress() Yunfeng Ye
2019-09-19 6:12 ` Zhou Wang
@ 2019-09-20 13:00 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2019-09-20 13:00 UTC (permalink / raw)
To: Yunfeng Ye; +Cc: wangzhou1, davem, linux-crypto, linux-kernel
On Mon, Sep 16, 2019 at 02:38:25PM +0800, Yunfeng Ye wrote:
> The return valude of add_comp_head() is int, but @head_size is size_t,
> which is a unsigned type.
>
> size_t head_size;
> ...
> if (head_size < 0) // it will never work
> return -ENOMEM
>
> Modify the type of @head_size to int, then change the type to size_t
> when invoke hisi_zip_create_req() as a parameter.
>
> Fixes: 62c455ca853e ("crypto: hisilicon - add HiSilicon ZIP accelerator support")
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> ---
> drivers/crypto/hisilicon/zip/zip_crypto.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-20 13:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-16 6:38 [PATCH] crypto: hisilicon - Fix return value check in hisi_zip_acompress() Yunfeng Ye
2019-09-19 6:12 ` Zhou Wang
2019-09-20 13:00 ` Herbert Xu
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).