Skip to content

Commit

Permalink
crypto: hisilicon - Fix return value check in hisi_zip_acompress()
Browse files Browse the repository at this point in the history
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: 62c455c ("crypto: hisilicon - add HiSilicon ZIP accelerator support")
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
Acked-by: Zhou Wang <wangzhou1@hisilicon.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Yunfeng Ye authored and Herbert Xu committed Sep 20, 2019
1 parent e00371a commit 62a9d9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/hisilicon/zip/zip_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,15 @@ 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 */
head_size = add_comp_head(acomp_req->dst, qp_ctx->qp->req_type);
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);

Expand Down

0 comments on commit 62a9d9f

Please sign in to comment.