public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@qlogic.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Dept-Eng QLA2xxx Upstream <qla2xxx-upstream@qlogic.com>
Cc: "James E.J. Bottomley" <JBottomley@odin.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [patch] qla2xxx: fix a timeout loop
Date: Thu, 17 Dec 2015 01:25:16 +0000	[thread overview]
Message-ID: <D2974DA7.CE3FD%himanshu.madhani@qlogic.com> (raw)
In-Reply-To: <20151216110746.GB21018@mwanda>

Hi Dan, 


On 12/16/15, 3:07 AM, "linux-scsi-owner@vger.kernel.org on behalf of Dan
Carpenter" <linux-scsi-owner@vger.kernel.org on behalf of
dan.carpenter@oracle.com> 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@oracle.com>
>
>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@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2015-12-17  1:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16 11:07 [patch] qla2xxx: fix a timeout loop Dan Carpenter
2015-12-16 11:45 ` Johannes Thumshirn
2015-12-16 22:50 ` Martin K. Petersen
2015-12-17 10:46   ` Dan Carpenter
2015-12-17 16:47     ` Martin K. Petersen
2015-12-17  1:25 ` Himanshu Madhani [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D2974DA7.CE3FD%himanshu.madhani@qlogic.com \
    --to=himanshu.madhani@qlogic.com \
    --cc=JBottomley@odin.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=qla2xxx-upstream@qlogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox