+ scsi-fix-incorrect-scsi-transfer-length-computation-from-odd-sized-scsi_execute_async-transfers.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     scsi: fix incorrect SCSI transfer length computation from odd sized scsi_execute_async() transfers
has been added to the -mm tree.  Its filename is
     scsi-fix-incorrect-scsi-transfer-length-computation-from-odd-sized-scsi_execute_async-transfers.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: scsi: fix incorrect SCSI transfer length computation from odd sized scsi_execute_async() transfers
From: Mike Christie <michaelc@xxxxxxxxxxx>

sg's may have setup a the buffer with a different length than the transfer
length so we should be using the bufflen passed in as the request's data
len.

Signed-off-by: Mike Christie <michaelc@xxxxxxxxxxx>
Cc: Jeremy Linton <jli@xxxxxxxxxxxxxxxxxx>
Cc: James Bottomley <James.Bottomley@xxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 drivers/scsi/scsi_lib.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff -puN drivers/scsi/scsi_lib.c~scsi-fix-incorrect-scsi-transfer-length-computation-from-odd-sized-scsi_execute_async-transfers drivers/scsi/scsi_lib.c
--- a/drivers/scsi/scsi_lib.c~scsi-fix-incorrect-scsi-transfer-length-computation-from-odd-sized-scsi_execute_async-transfers
+++ a/drivers/scsi/scsi_lib.c
@@ -306,7 +306,7 @@ static int scsi_req_map_sg(struct reques
 {
 	struct request_queue *q = rq->q;
 	int nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
-	unsigned int data_len = 0, len, bytes, off;
+	unsigned int data_len = bufflen, len, bytes, off;
 	struct page *page;
 	struct bio *bio = NULL;
 	int i, err, nr_vecs = 0;
@@ -315,10 +315,15 @@ static int scsi_req_map_sg(struct reques
 		page = sgl[i].page;
 		off = sgl[i].offset;
 		len = sgl[i].length;
-		data_len += len;
 
-		while (len > 0) {
+		while (len > 0 && data_len > 0) {
+			/*
+			 * sg sends a scatterlist that is larger than
+			 * the data_len it wants transferred for certain
+			 * IO sizes
+			 */
 			bytes = min_t(unsigned int, len, PAGE_SIZE - off);
+			bytes = min(bytes, data_len);
 
 			if (!bio) {
 				nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages);
@@ -350,12 +355,13 @@ static int scsi_req_map_sg(struct reques
 
 			page++;
 			len -= bytes;
+			data_len -=bytes;
 			off = 0;
 		}
 	}
 
 	rq->buffer = rq->data = NULL;
-	rq->data_len = data_len;
+	rq->data_len = bufflen;
 	return 0;
 
 free_bios:
_

Patches currently in -mm which might be from michaelc@xxxxxxxxxxx are

git-scsi-misc.patch
add-includes-to-scsi_transport_iscsih.patch
scsi-fix-incorrect-scsi-transfer-length-computation-from-odd-sized-scsi_execute_async-transfers.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux