Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: hisilicon/sec2 - Fix false-positive warning of uninitialised qp_ctx

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>

+3 -5
+3 -5
drivers/crypto/hisilicon/sec2/sec_crypto.c
··· 1944 1944 static int sec_request_init(struct sec_ctx *ctx, struct sec_req *req) 1945 1945 { 1946 1946 struct sec_qp_ctx *qp_ctx; 1947 - int i; 1947 + int i = 0; 1948 1948 1949 - for (i = 0; i < ctx->sec->ctx_q_num; i++) { 1949 + do { 1950 1950 qp_ctx = &ctx->qp_ctx[i]; 1951 1951 req->req_id = sec_alloc_req_id(req, qp_ctx); 1952 - if (req->req_id >= 0) 1953 - break; 1954 - } 1952 + } while (req->req_id < 0 && ++i < ctx->sec->ctx_q_num); 1955 1953 1956 1954 req->qp_ctx = qp_ctx; 1957 1955 req->backlog = &qp_ctx->backlog;