Skip to contentSkip to conversation

crypto: hisilicon - Fix return value check in hisi_zip_acompress()

PATCH In review Yunfeng Ye 3 participants 3 messages Sep 16, 2019 – Sep 20, 2019

Subsystems (2)
lore
Share & tools
lore

Yunfeng Ye

author
#0 lore raw

PATCH 1/1 crypto: hisilicon - Fix return value check in hisi_zip_acompress()

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")
---
 drivers/crypto/hisilicon/zip/zip_crypto.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/zip/zip_crypto.c +2 -2
index 5a3f84d..5902354 100644
@@ -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);
 
Signature · 1 line
2.7.4.huawei.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Yunfeng Ye

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.

This is a bug, thinks for your fix!

Best,
Zhou

Quoted 29 lines
Fixes 62c455ca853e ("crypto: hisilicon - add HiSilicon ZIP accelerator support")
---
 drivers/crypto/hisilicon/zip/zip_crypto.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/zip/zip_crypto.c +2 -2
index 5a3f84d..5902354 100644
@@ -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);
 
maintainer
#2 lore raw
In reply to Yunfeng Ye
Quoted 8 lines · Yunfeng Ye

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
Quoted 8 lines

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")
---
 drivers/crypto/hisilicon/zip/zip_crypto.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt