Skip to contentSkip to conversation

libata: fix WARN_ON() condition in *_fill_sg()

PATCH New Tejun Heo 1 participant 1 message Feb 17, 2006

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 libata: fix WARN_ON() condition in *_fill_sg()

For ATAPI commands, padding can reduce qc->n_elem by one and thus to zero making WARN_ON(qc->n_elem == 0) in ata_fill_sg() and qs_fill_sg() trigger for legal commands. This patch fixes the WARN_ON() conditions to take qc->pad_len into account.

Although the condition check seems a bit excessive, as this part of code isn't still stable yet, I think it's worth to keep those.

---

Jeff, this patch is against the current #upstream[1]. Without this patch trying to burn a cd with cdrecord on sii3114 results in a log of Badness messages. One of offending commands is MODE_SENSE(10) with data size of 2 to find out mode page size. Padding leaves no sg entry and the Badness gets trigerred.

[1] f1b318793dcd2d9ff6b5ac06e7762098fa079cee

 libata-core.c |    2 +-
 sata_qstor.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/libata-core.c +1 -1
index 61cba39..f7fa69f 100644
@@ -2639,7 +2639,7 @@ static void ata_fill_sg(struct ata_queue
 	unsigned int idx;
 
 	WARN_ON(qc->__sg == NULL);
-	WARN_ON(qc->n_elem == 0);
+	WARN_ON(qc->n_elem == 0 && qc->pad_len == 0);
 
 	idx = 0;
 	ata_for_each_sg(sg, qc) {
drivers/scsi/sata_qstor.c +1 -1
index 2864826..9602f43 100644
@@ -277,7 +277,7 @@ static unsigned int qs_fill_sg(struct at
 	u8 *prd = pp->pkt + QS_CPB_BYTES;
 
 	WARN_ON(qc->__sg == NULL);
-	WARN_ON(qc->n_elem == 0);
+	WARN_ON(qc->n_elem == 0 && qc->pad_len == 0);
 
 	nelem = 0;
 	ata_for_each_sg(sg, qc) {