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

scsi: pm80xx: Fix potential infinite loop

The for-loop iterates with a u8 loop counter i and compares this with the
loop upper limit of pm8001_ha->max_q_num which is a u32 type. There is a
potential infinite loop if pm8001_ha->max_q_num is larger than the u8 loop
counter. Fix this by making the loop counter the same type as
pm8001_ha->max_q_num.

[mkp: this is purely theoretical, max_q_num is currently limited to 64]

Link: https://lore.kernel.org/r/20210407135840.494747-1-colin.king@canonical.com
Fixes: 65df7d1986a1 ("scsi: pm80xx: Fix chip initialization failure")
Addresses-Coverity: ("Infinite loop")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Colin Ian King and committed by
Martin K. Petersen
40fa7394 6f305bf6

+1 -1
+1 -1
drivers/scsi/pm8001/pm8001_hwi.c
··· 643 643 */ 644 644 static int pm8001_chip_init(struct pm8001_hba_info *pm8001_ha) 645 645 { 646 - u8 i = 0; 646 + u32 i = 0; 647 647 u16 deviceid; 648 648 pci_read_config_word(pm8001_ha->pdev, PCI_DEVICE_ID, &deviceid); 649 649 /* 8081 controllers need BAR shift to access MPI space