]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: hisilicon/sec2 - Fix false-positive warning of uninitialised qp_ctx
authorHerbert Xu <herbert@gondor.apana.org.au>
Sat, 30 Aug 2025 08:39:15 +0000 (16:39 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 6 Sep 2025 07:57:23 +0000 (15:57 +0800)
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>
Reviewed-by: Longfang Liu <liulongfang@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/hisilicon/sec2/sec_crypto.c

index d044ded0f290494db0f87605f8916a4170d52e2c..31590d01139a37195f9cf653644bf394e07e2c83 100644 (file)
@@ -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;