Skip to content

Commit

Permalink
[PATCH] sg traverse fix for __atapi_pio_bytes()
Browse files Browse the repository at this point in the history
Problem:
Incorrect md5sum when using ATAPI PIO mode to verify a distro CD.

Root cause:  sg traverse problem.
In __atapi_pio_bytes(), if qc->cursg++ is increased and "goto
next_page" is executed, then sg is not updated to the new qc->cursg
and the old sg is overwritten with the new data.

Changes:
- Replace "goto next_page" with "goto next_sg" to make sg updated.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
  • Loading branch information
Albert Lee authored and Jeff Garzik committed Jun 9, 2005
1 parent e1dd23a commit 6952df0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/scsi/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,14 +2577,14 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
next_sg:
sg = &qc->sg[qc->cursg];

next_page:
page = sg->page;
offset = sg->offset + qc->cursg_ofs;

/* get the current page and offset */
page = nth_page(page, (offset >> PAGE_SHIFT));
offset %= PAGE_SIZE;

/* don't overrun current sg */
count = min(sg->length - qc->cursg_ofs, bytes);

/* don't cross page boundaries */
Expand All @@ -2609,8 +2609,6 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
kunmap(page);

if (bytes) {
if (qc->cursg_ofs < sg->length)
goto next_page;
goto next_sg;
}
}
Expand Down

0 comments on commit 6952df0

Please sign in to comment.