--- libata-2.6-sgdma/drivers/scsi/libata-core.c 2005-03-17 17:23:42.000000000 +0800 +++ libata-2.6-atapi_pio_bytes/drivers/scsi/libata-core.c 2005-03-18 13:20:01.000000000 +0800 @@ -2340,7 +2340,6 @@ next_sg: sg = &qc->sg[qc->cursg]; -next_page: page = sg->page; offset = sg->offset + qc->cursg_ofs; @@ -2348,6 +2347,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 */ @@ -2372,8 +2372,6 @@ kunmap(page); if (bytes) { - if (qc->cursg_ofs < sg->length) - goto next_page; goto next_sg; } }