--- d49dc21d4cb4a4117c570e5818dee8b2ec5a19eb +++ 2a4b147b0b388aa1b718eb2fa1a471bfca64e0f7 @@ -532,7 +532,7 @@ static unsigned int copy_to_bounce_buffe ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); - if (j == 0) + if (bounce_addr == 0) bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0); while (srclen) { @@ -593,7 +593,7 @@ static unsigned int copy_from_bounce_buf destlen = orig_sgl[i].length; ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); - if (j == 0) + if (bounce_addr == 0) bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0); while (destlen) { @@ -652,6 +652,7 @@ static int storvsc_queuecommand(struct s unsigned int request_size = 0; int i; struct scatterlist *sgl; + unsigned int sg_count = 0; DPRINT_ENTER(STORVSC_DRV); @@ -736,6 +737,7 @@ static int storvsc_queuecommand(struct s request->DataBuffer.Length = scsi_bufflen(scmnd); if (scsi_sg_count(scmnd)) { sgl = (struct scatterlist *)scsi_sglist(scmnd); + sg_count = scsi_sg_count(scmnd); /* check if we need to bounce the sgl */ if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) { @@ -770,11 +772,12 @@ static int storvsc_queuecommand(struct s scsi_sg_count(scmnd)); sgl = cmd_request->bounce_sgl; + sg_count = cmd_request->bounce_sgl_count; } request->DataBuffer.Offset = sgl[0].offset; - for (i = 0; i < scsi_sg_count(scmnd); i++) { + for (i = 0; i < sg_count; i++) { DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d \n", i, sgl[i].length, sgl[i].offset); request->DataBuffer.PfnArray[i] =