Skip to content

Commit d4bc0a2

Browse files
mpedamien-lemoal
authored andcommitted
ata: pata_macio: Use WARN instead of BUG
The overflow/underflow conditions in pata_macio_qc_prep() should never happen. But if they do there's no need to kill the system entirely, a WARN and failing the IO request should be sufficient and might allow the system to keep running. Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Damien Le Moal <[email protected]>
1 parent 822c802 commit d4bc0a2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/ata/pata_macio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ static enum ata_completion_errors pata_macio_qc_prep(struct ata_queued_cmd *qc)
554554

555555
while (sg_len) {
556556
/* table overflow should never happen */
557-
BUG_ON (pi++ >= MAX_DCMDS);
557+
if (WARN_ON_ONCE(pi >= MAX_DCMDS))
558+
return AC_ERR_SYSTEM;
558559

559560
len = (sg_len < MAX_DBDMA_SEG) ? sg_len : MAX_DBDMA_SEG;
560561
table->command = cpu_to_le16(write ? OUTPUT_MORE: INPUT_MORE);
@@ -566,11 +567,13 @@ static enum ata_completion_errors pata_macio_qc_prep(struct ata_queued_cmd *qc)
566567
addr += len;
567568
sg_len -= len;
568569
++table;
570+
++pi;
569571
}
570572
}
571573

572574
/* Should never happen according to Tejun */
573-
BUG_ON(!pi);
575+
if (WARN_ON_ONCE(!pi))
576+
return AC_ERR_SYSTEM;
574577

575578
/* Convert the last command to an input/output */
576579
table--;

0 commit comments

Comments
 (0)