Skip to content

Commit

Permalink
crypto: cavium - Fix the if condition to exit loop after timeout
Browse files Browse the repository at this point in the history
The while loop breaks in the first run because of incorrect
if condition. It also causes the statements after the if to
appear dead.
Fix this by changing the condition from if(timeout--) to
if(!timeout--).

This bug was reported by Coverity Scan.
Report:
CID 1600859: (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: udelay(30UL);

Fixes: 9e2c7d9 ("crypto: cavium - Add Support for Octeon-tx CPT Engine")
Signed-off-by: Everest K.C. <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
everestkc authored and herbertx committed Oct 28, 2024
1 parent 7a42b7b commit 53d91ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/cavium/cpt/cptpf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void cpt_disable_cores(struct cpt_device *cpt, u64 coremask,
dev_err(dev, "Cores still busy %llx", coremask);
grp = cpt_read_csr64(cpt->reg_base,
CPTX_PF_EXEC_BUSY(0));
if (timeout--)
if (!timeout--)
break;

udelay(CSR_DELAY);
Expand Down Expand Up @@ -394,7 +394,7 @@ static void cpt_disable_all_cores(struct cpt_device *cpt)
dev_err(dev, "Cores still busy");
grp = cpt_read_csr64(cpt->reg_base,
CPTX_PF_EXEC_BUSY(0));
if (timeout--)
if (!timeout--)
break;

udelay(CSR_DELAY);
Expand Down

0 comments on commit 53d91ca

Please sign in to comment.