All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Sergey Shtylyov <s.shtylyov@omp.ru>
Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	linux-ide@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] ata: pata_hpt37x: fix potential forever loop
Date: Wed, 1 Feb 2023 17:10:30 +0300	[thread overview]
Message-ID: <Y9py1vjPW5HgRwOR@kili> (raw)

This code accidentally reuses the "tries" iterator for both the inside
and outside loops.  It could result in a forever loop if the "tries"
variable gets reset to 0x1000 and never reaches 0x5000.

Fixes: 669a5db411d8 ("[libata] Add a bunch of PATA drivers.")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/ata/pata_hpt37x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index ce3c5eaa7e76..35be9a095b18 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -621,14 +621,14 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
 {
 	u8 reg5b;
 	u32 reg5c;
-	int tries;
+	int tries, tries2;
 
 	for (tries = 0; tries < 0x5000; tries++) {
 		udelay(50);
 		pci_read_config_byte(dev, 0x5b, &reg5b);
 		if (reg5b & 0x80) {
 			/* See if it stays set */
-			for (tries = 0; tries < 0x1000; tries++) {
+			for (tries2 = 0; tries2 < 0x1000; tries2++) {
 				pci_read_config_byte(dev, 0x5b, &reg5b);
 				/* Failed ? */
 				if ((reg5b & 0x80) == 0)
-- 
2.35.1


             reply	other threads:[~2023-02-01 14:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 14:10 Dan Carpenter [this message]
2023-02-01 14:59 ` [PATCH] ata: pata_hpt37x: fix potential forever loop Sergey Shtylyov
2023-02-01 17:18   ` Sergey Shtylyov
2023-02-02  6:42     ` Dan Carpenter

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=Y9py1vjPW5HgRwOR@kili \
    --to=error27@gmail.com \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=s.shtylyov@omp.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.