Skip to contentSkip to conversation

pata_legacy: fix a couple uninitialized variable bugs

PATCH Applied Dan Carpenter 2 participants 3 messages Oct 6, 2021 – Oct 12, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pata_legacy: fix a couple uninitialized variable bugs

The last byte of "pad" is used without being initialized.

Fixes 55dba3120fbc ("libata: update ->data_xfer hook for ATAPI")
---
 drivers/ata/pata_legacy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/pata_legacy.c +2 -2
index c3e6592712c4..b53f0e09783d 100644
@@ -352,7 +352,7 @@ static unsigned int pdc_data_xfer_vlb(struct ata_queued_cmd *qc,
 			iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
 		if (unlikely(slop)) {
-			__le32 pad;
+			__le32 pad = 0;
 			if (rw == READ) {
 				pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
 				memcpy(buf + buflen - slop, &pad, slop);
@@ -742,7 +742,7 @@ static unsigned int vlb32_data_xfer(struct ata_queued_cmd *qc,
 			ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
 		if (unlikely(slop)) {
-			__le32 pad;
+			__le32 pad = 0;
 			if (rw == WRITE) {
 				memcpy(&pad, buf + buflen - slop, slop);
 				iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 23 lines · Dan Carpenter

The last byte of "pad" is used without being initialized.

Fixes 55dba3120fbc ("libata: update ->data_xfer hook for ATAPI")
---
 drivers/ata/pata_legacy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/pata_legacy.c +1 -1
index c3e6592712c4..b53f0e09783d 100644
@@ -352,7 +352,7 @@ static unsigned int pdc_data_xfer_vlb(struct ata_queued_cmd *qc,
 			iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
 		if (unlikely(slop)) {
-			__le32 pad;
+			__le32 pad = 0;
 			if (rw == READ) {
 				pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
 				memcpy(buf + buflen - slop, &pad, slop);

drivers/ata/pata_legacy.c static unsigned int vlb32_data_xfer(struct ata_queued_cmd *qc, · line 748

Quoted 8 lines
drivers/ata/pata_legacy.c +1 -1
@@ -742,7 +742,7 @@ static unsigned int vlb32_data_xfer(struct ata_queued_cmd *qc,
 			ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
 		if (unlikely(slop)) {
-			__le32 pad;
+			__le32 pad = 0;
 			if (rw == WRITE) {
 				memcpy(&pad, buf + buflen - slop, slop);
 				iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);

Applied to for-5.15-fixes. Thanks !
(Note: I added a blank line after the pad declaration to follow kernel style).

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

(Note: I added a blank line after the pad declaration to follow kernel style).

I wanted to do that too, but took the more conservative approach. Thanks!

regards,
dan carpenter