Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ae61c6c authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik
Browse files

[PATCH] libata: fix WARN_ON() condition in *_fill_sg()



For ATAPI commands, padding can reduce qc->n_elem by one and thus to
zero making assert(qc->n_elem > 0)'s in ata_fill_sg() and qs_fill_sg()
fail for legal commands.  This patch fixes the assert()'s 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.

Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent bd71c2b1
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -2570,7 +2570,7 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
	unsigned int idx;
	unsigned int idx;


	assert(qc->__sg != NULL);
	assert(qc->__sg != NULL);
	assert(qc->n_elem > 0);
	assert(qc->n_elem > 0 || qc->pad_len > 0);


	idx = 0;
	idx = 0;
	ata_for_each_sg(sg, qc) {
	ata_for_each_sg(sg, qc) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -277,7 +277,7 @@ static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
	u8 *prd = pp->pkt + QS_CPB_BYTES;
	u8 *prd = pp->pkt + QS_CPB_BYTES;


	assert(qc->__sg != NULL);
	assert(qc->__sg != NULL);
	assert(qc->n_elem > 0);
	assert(qc->n_elem > 0 || qc->pad_len > 0);


	nelem = 0;
	nelem = 0;
	ata_for_each_sg(sg, qc) {
	ata_for_each_sg(sg, qc) {