scsi: lpfc: Fix less-than-zero comparison of unsigned value
authorDick Kennedy <dick.kennedy@broadcom.com>
Mon, 6 Jul 2020 20:42:46 +0000 (13:42 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 8 Jul 2020 05:28:49 +0000 (01:28 -0400)
commit77dd7d7b344283a3bce334d0f43fc2c0629ffe48
tree44169cd8b12ab1af9f658b775cf9619a4584b690
parent17105d959b268ce181d877d9ff2ead5b112ce4a4
scsi: lpfc: Fix less-than-zero comparison of unsigned value

The expression start_idx - dbg_cnt is evaluated using unsigned int
arthithmetic (since these variables are unsigned ints) and hence can never
be less than zero, so the less than comparison is never true.  Rewrite the
expression to check for start_idx being less than dbg_cnt.

After the logic was corrected, temp_idx wasn't working correctly. So fix it
as well.

Link: https://lore.kernel.org/r/20200706204246.130416-1-jsmart2021@gmail.com
Fixes: 372c187b8a70 ("scsi: lpfc: Add an internal trace log buffer")
CC: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Addresses-Coverity: ("Unsigned compared against 0")
drivers/scsi/lpfc/lpfc_init.c