Re: [patch] qla2xxx: fix a timeout loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan, 


On 12/16/15, 3:07 AM, "linux-scsi-owner@xxxxxxxxxxxxxxx on behalf of Dan
Carpenter" <linux-scsi-owner@xxxxxxxxxxxxxxx on behalf of
dan.carpenter@xxxxxxxxxx> wrote:

>After the loop we test for "if (!retries) " as a failure, but actually
>the post-op here will end with retries set to -1.  I have fixed this by
>using a pre-op instead.
>
>Fixes: 7ec0effd30bb ('[SCSI] qla2xxx: Add support for ISP8044.')
>Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
>
>diff --git a/drivers/scsi/qla2xxx/qla_nx2.c
>b/drivers/scsi/qla2xxx/qla_nx2.c
>index 007192d..66d629e 100644
>--- a/drivers/scsi/qla2xxx/qla_nx2.c
>+++ b/drivers/scsi/qla2xxx/qla_nx2.c
>@@ -3491,7 +3491,7 @@ qla8044_poll_flash_status_reg(struct scsi_qla_host
>*vha)
> 	int retries = QLA8044_FLASH_READ_RETRY_COUNT;
> 	int ret_val = QLA_SUCCESS;
> 
>-	while (retries--) {
>+	while (--retries) {
> 		ret_val = qla8044_rd_reg_indirect(vha, QLA8044_FLASH_STATUS,
> 		    &flash_status);
> 		if (ret_val) {

There is flaw in this pre-decrement logic here for following 2 reasons
1. The pre-decrement reduces the total number of retries by one
2. If the retries is already Zero, then the pre-decrement would cause loop
to iterate for a very large number of times.

The correct fix for this would be to change the if(!retries) to if
(retries == -1) or if (retries < 0)

We¹ll send a follow up patch to fix this.

Thanks,
Himanshu
>--
>To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>the body of a message to majordomo@xxxxxxxxxxxxxxx
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

<<attachment: winmail.dat>>


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux