2020-09-10 21:56:06

by liulongfang

[permalink] [raw]
Subject: [PATCH 0/5] crypto: hisilicon - update ACC module parameter

In order to pass kernel crypto test, the ACC module parameter
pf_q_num needs to be set to an integer greater than 1,
and then fixed two bugs.

Longfang Liu (5):
crypto: hisilicon - update mininum queue
crypto: hisilicon - update HPRE module parameter description
crypto: hisilicon - update SEC module parameter description
crypto: hisilicon - update ZIP module parameter description
crypto: hisilicon - fixed memory allocation error

drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +-
drivers/crypto/hisilicon/qm.h | 4 ++--
drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 ++++++++++++----
drivers/crypto/hisilicon/sec2/sec_main.c | 2 +-
drivers/crypto/hisilicon/zip/zip_main.c | 2 +-
5 files changed, 17 insertions(+), 9 deletions(-)

--
2.8.1


2020-09-10 21:56:07

by liulongfang

[permalink] [raw]
Subject: [PATCH 5/5] crypto: hisilicon - fixed memory allocation error

1. Fix the bug of 'mac' memory leak as allocating 'pbuf' failing.
2. Fix the bug of 'qps' leak as allocating 'qp_ctx' failing.

Signed-off-by: Longfang Liu <[email protected]>
---
drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index 543d9ee..bb49342 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -340,11 +340,14 @@ static int sec_alg_resource_alloc(struct sec_ctx *ctx,
ret = sec_alloc_pbuf_resource(dev, res);
if (ret) {
dev_err(dev, "fail to alloc pbuf dma resource!\n");
- goto alloc_fail;
+ goto alloc_pbuf_fail;
}
}

return 0;
+alloc_pbuf_fail:
+ if (ctx->alg_type == SEC_AEAD)
+ sec_free_mac_resource(dev, qp_ctx->res);
alloc_fail:
sec_free_civ_resource(dev, res);

@@ -455,8 +458,10 @@ static int sec_ctx_base_init(struct sec_ctx *ctx)
ctx->fake_req_limit = QM_Q_DEPTH >> 1;
ctx->qp_ctx = kcalloc(sec->ctx_q_num, sizeof(struct sec_qp_ctx),
GFP_KERNEL);
- if (!ctx->qp_ctx)
- return -ENOMEM;
+ if (!ctx->qp_ctx) {
+ ret = -ENOMEM;
+ goto err_destroy_qps;
+ }

for (i = 0; i < sec->ctx_q_num; i++) {
ret = sec_create_qp_ctx(&sec->qm, ctx, i, 0);
@@ -465,12 +470,15 @@ static int sec_ctx_base_init(struct sec_ctx *ctx)
}

return 0;
+
err_sec_release_qp_ctx:
for (i = i - 1; i >= 0; i--)
sec_release_qp_ctx(ctx, &ctx->qp_ctx[i]);

- sec_destroy_qps(ctx->qps, sec->ctx_q_num);
kfree(ctx->qp_ctx);
+err_destroy_qps:
+ sec_destroy_qps(ctx->qps, sec->ctx_q_num);
+
return ret;
}

--
2.8.1

2020-09-11 01:06:05

by liulongfang

[permalink] [raw]
Subject: Re: [PATCH 0/5] crypto: hisilicon - update ACC module parameter


On 2020/9/10 20:56, Longfang Liu Wrote:
> In order to pass kernel crypto test, the ACC module parameter
> pf_q_num needs to be set to an integer greater than 1,
> and then fixed two bugs.
>
> Longfang Liu (5):
> crypto: hisilicon - update mininum queue
> crypto: hisilicon - update HPRE module parameter description
> crypto: hisilicon - update SEC module parameter description
> crypto: hisilicon - update ZIP module parameter description
> crypto: hisilicon - fixed memory allocation error
>
> drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +-
> drivers/crypto/hisilicon/qm.h | 4 ++--
> drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 ++++++++++++----
> drivers/crypto/hisilicon/sec2/sec_main.c | 2 +-
> drivers/crypto/hisilicon/zip/zip_main.c | 2 +-
> 5 files changed, 17 insertions(+), 9 deletions(-)

Hi, Herbert

Please omit this patch set!

Due to my mailbox error, I sent this patch set again。

Sorry for this.