Skip to contentSkip to conversation

ata: libata-sff: fix reading uninitialized variable in ata_sff_lost_interrupt()

PATCH In review Sergey Shtylyov 2 participants 6 messages Feb 18, 2022 – Feb 19, 2022 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: libata-sff: fix reading uninitialized variable in ata_sff_lost_interrupt()

Due to my sloppy coding in commit 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()"), in ata_sff_lost_interrupt() iff the device control register doesn't exists, ata_port_warn() would print the 'status' variable
which never gets assigned. Restore the original order of the statements,
wrapping the ata_sff_altstatus() call in WARN_ON_ONCE()...

While at it, fix crazy indentation in the ata_port_warn() call itself...

Fixes 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()")
---
 drivers/ata/libata-sff.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/ata/libata-sff.c +4 -3
Index: libata/drivers/ata/libata-sff.c
===================================================================
@@ -1644,13 +1644,14 @@ void ata_sff_lost_interrupt(struct ata_p
 		return;
 	/* See if the controller thinks it is still busy - if so the command
 	   isn't a lost IRQ but is still in progress */
-	if (ata_sff_altstatus(ap, &status) && (status & ATA_BUSY))
+	if (WARN_ON_ONCE(!ata_sff_altstatus(ap, &status)))
+		return;
+	if (status & ATA_BUSY)
 		return;
 
 	/* There was a command running, we are no longer busy and we have
 	   no interrupt. */
-	ata_port_warn(ap, "lost interrupt (Status 0x%x)\n",
-								status);
+	ata_port_warn(ap, "lost interrupt (Status 0x%x)\n", status);
 	/* Run the host interrupt logic as if the interrupt had not been
 	   lost */
 	ata_sff_port_intr(ap, qc);
#1 lore raw
Quoted 6 lines · Sergey Shtylyov

Due to my sloppy coding in commit 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()"), in ata_sff_lost_interrupt() iff the device control register doesn't exists, ata_port_warn() would print the 'status' variable
which never gets assigned. Restore the original order of the statements,
wrapping the ata_sff_altstatus() call in WARN_ON_ONCE()...

Quoted 8 lines

While at it, fix crazy indentation in the ata_port_warn() call itself...

Fixes 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()")

---

Forgot to mention that it's against the 'for-next' branch of 'libata.git'. :-/

[...]

MBR, Sergey

#2 lore raw
Quoted 10 lines · Sergey Shtylyov
Quoted 8 lines · Sergey Shtylyov

Due to my sloppy coding in commit 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()"), in ata_sff_lost_interrupt() iff the device control register doesn't exists, ata_port_warn() would print the 'status' variable
which never gets assigned. Restore the original order of the statements,
wrapping the ata_sff_altstatus() call in WARN_ON_ONCE()...

While at it, fix crazy indentation in the ata_port_warn() call itself...

Quoted 8 lines
Quoted 6 lines
Fixes 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()")

---

Forgot to mention that it's against the 'for-next' branch of 'libata.git'. :-/

No need to mention it, it always should be :)

Quoted 4 lines

[...]

MBR, Sergey

Signature · 2 lines
Damien Le Moal
Western Digital Research
#3 lore raw
In reply to Sergey Shtylyov
Quoted 6 lines · Sergey Shtylyov

Due to my sloppy coding in commit 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()"), in ata_sff_lost_interrupt() iff the device control register doesn't exists, ata_port_warn() would print the 'status' variable
which never gets assigned. Restore the original order of the statements,
wrapping the ata_sff_altstatus() call in WARN_ON_ONCE()...

Quoted 6 lines

While at it, fix crazy indentation in the ata_port_warn() call itself...

Fixes 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()")

I squashed this in the commit being fixed.

Dan,

Thanks for the report !

Signature · 2 lines
Damien Le Moal
Western Digital Research
#4 lore raw
Quoted 6 lines · Damien Le Moal
Quoted 6 lines

Due to my sloppy coding in commit 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()"), in ata_sff_lost_interrupt() iff the device control register doesn't exists, ata_port_warn() would print the 'status' variable
which never gets assigned. Restore the original order of the statements,
wrapping the ata_sff_altstatus() call in WARN_ON_ONCE()...

Quoted 8 lines
Quoted 6 lines

While at it, fix crazy indentation in the ata_port_warn() call itself...

Fixes 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()")

I squashed this in the commit being fixed.

I'm seeing a few typos/errors in the updated patch #2:

Quoted 1 line

In ata_sff_lost_interrupt(), wrap the ata_sff_altstatus() call in a

s/a/the/?

Quoted 1 line

WARN_ON_ONCE()

+ check?

Quoted 1 line

to issue a warning if the if the device control registert

Register? :-)

Quoted 2 lines

does not exist. And while at it, fix crazy indentation in the ata_port_warn() call itself...

Not clear why you (we?) emphasize this by using "itself"...

Well, if you choose to fix those, I'll be thnakful. But you may as well
ignore me. :-)

[...]

MBR, Sergey

#5 lore raw
Quoted 31 lines · Sergey Shtylyov
Quoted 6 lines · Damien Le Moal
Quoted 6 lines

Due to my sloppy coding in commit 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()"), in ata_sff_lost_interrupt() iff the device control register doesn't exists, ata_port_warn() would print the 'status' variable
which never gets assigned. Restore the original order of the statements,
wrapping the ata_sff_altstatus() call in WARN_ON_ONCE()...

Quoted 8 lines
Quoted 6 lines

While at it, fix crazy indentation in the ata_port_warn() call itself...

Fixes 2c75a451ecb0 ("ata: libata-sff: refactor ata_sff_altstatus()")

I squashed this in the commit being fixed.

I'm seeing a few typos/errors in the updated patch #2:

Quoted 1 line

In ata_sff_lost_interrupt(), wrap the ata_sff_altstatus() call in a

s/a/the/?

Quoted 1 line

WARN_ON_ONCE()

+ check?

Quoted 1 line

to issue a warning if the if the device control registert

   Register? :-)
Quoted 7 lines
Quoted 2 lines

does not exist. And while at it, fix crazy indentation in the ata_port_warn() call itself...

Not clear why you (we?) emphasize this by using "itself"...

Well, if you choose to fix those, I'll be thnakful. But you may as well
ignore me. :-)

Will fix that. Thanks for checking.

Quoted 4 lines

[...]

MBR, Sergey

Signature · 2 lines
Damien Le Moal
Western Digital Research