* [PATCH] crypto: hisilicon/sec2 - Fix false-positive warning of uninitialised qp_ctx
@ 2025-08-30 8:39 Herbert Xu
2025-08-30 9:04 ` liulongfang
0 siblings, 1 reply; 2+ messages in thread
From: Herbert Xu @ 2025-08-30 8:39 UTC (permalink / raw)
To: Linux Crypto Mailing List, Longfang Liu
Fix the false-positive warning of qp_ctx being unitialised in
sec_request_init. The value of ctx_q_num defaults to 2 and is
guaranteed to be non-zero.
Thus qp_ctx is always initialised. However, the compiler is
not aware of this constraint on ctx_q_num. Restructure the loop
so that it is obvious to the compiler that ctx_q_num cannot be
zero.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index d044ded0f290..31590d01139a 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -1944,14 +1944,12 @@ static void sec_request_uninit(struct sec_req *req)
static int sec_request_init(struct sec_ctx *ctx, struct sec_req *req)
{
struct sec_qp_ctx *qp_ctx;
- int i;
+ int i = 0;
- for (i = 0; i < ctx->sec->ctx_q_num; i++) {
+ do {
qp_ctx = &ctx->qp_ctx[i];
req->req_id = sec_alloc_req_id(req, qp_ctx);
- if (req->req_id >= 0)
- break;
- }
+ } while (req->req_id < 0 && ++i < ctx->sec->ctx_q_num);
req->qp_ctx = qp_ctx;
req->backlog = &qp_ctx->backlog;
--
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 related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: hisilicon/sec2 - Fix false-positive warning of uninitialised qp_ctx
2025-08-30 8:39 [PATCH] crypto: hisilicon/sec2 - Fix false-positive warning of uninitialised qp_ctx Herbert Xu
@ 2025-08-30 9:04 ` liulongfang
0 siblings, 0 replies; 2+ messages in thread
From: liulongfang @ 2025-08-30 9:04 UTC (permalink / raw)
To: Herbert Xu, Linux Crypto Mailing List
On 2025/8/30 16:39, Herbert Xu wrote:
> Fix the false-positive warning of qp_ctx being unitialised in
> sec_request_init. The value of ctx_q_num defaults to 2 and is
> guaranteed to be non-zero.
>
> Thus qp_ctx is always initialised. However, the compiler is
> not aware of this constraint on ctx_q_num. Restructure the loop
> so that it is obvious to the compiler that ctx_q_num cannot be
> zero.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
> index d044ded0f290..31590d01139a 100644
> --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
> +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
> @@ -1944,14 +1944,12 @@ static void sec_request_uninit(struct sec_req *req)
> static int sec_request_init(struct sec_ctx *ctx, struct sec_req *req)
> {
> struct sec_qp_ctx *qp_ctx;
> - int i;
> + int i = 0;
>
> - for (i = 0; i < ctx->sec->ctx_q_num; i++) {
> + do {
> qp_ctx = &ctx->qp_ctx[i];
> req->req_id = sec_alloc_req_id(req, qp_ctx);
> - if (req->req_id >= 0)
> - break;
> - }
> + } while (req->req_id < 0 && ++i < ctx->sec->ctx_q_num);
>
> req->qp_ctx = qp_ctx;
> req->backlog = &qp_ctx->backlog;
>
Reviewed-by: Longfang Liu <liulongfang@huawei.com>
Thanks
Longfang.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-30 9:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-30 8:39 [PATCH] crypto: hisilicon/sec2 - Fix false-positive warning of uninitialised qp_ctx Herbert Xu
2025-08-30 9:04 ` liulongfang
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).