--- 10_atapi_pio_fix/drivers/scsi/libata-core.c 2005-06-06 13:37:50.000000000 +0800 +++ 11_atapi_pio_sg_fix/drivers/scsi/libata-core.c 2005-06-06 13:45:33.000000000 +0800 @@ -2577,7 +2577,6 @@ next_sg: sg = &qc->sg[qc->cursg]; -next_page: page = sg->page; offset = sg->offset + qc->cursg_ofs; @@ -2585,6 +2584,7 @@ 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 */ @@ -2609,8 +2609,6 @@ kunmap(page); if (bytes) { - if (qc->cursg_ofs < sg->length) - goto next_page; goto next_sg; } }