linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 11/10] fix leak in scsi_req_map_sg
@ 2005-11-08 22:52 Mike Christie
  0 siblings, 0 replies; only message in thread
From: Mike Christie @ 2005-11-08 22:52 UTC (permalink / raw)
  To: Jens Axboe, linux-scsi

I guess this would be 11/10. I found a bug in testing.

I should not have been testing against bi_max_vecs. For odd
IO sizes it would cause us to leak bios. We should test against
the number of vecs we requested and were planning on adding.

All my patches are here
http://www.cs.wisc.edu/~michaelc/block/use-sg/v9/
this includes fixups Jens requested (hopefully they
are correct now). And they were made against scsi-misc.


--- scsi-misc-2.6/drivers/scsi/scsi_lib.c.orig	2005-11-08 16:45:28.000000000 -0600
+++ scsi-misc-2.6/drivers/scsi/scsi_lib.c	2005-11-08 16:45:55.000000000 -0600
@@ -369,7 +369,7 @@ static int scsi_req_map_sg(struct reques
 	unsigned int data_len = 0, len, bytes, off;
 	struct page *page;
 	struct bio *bio = NULL;
-	int i, err;
+	int i, err, nr_vecs = 0;
 
 	for (i = 0; i < nsegs; i++) {
 		page = sgl[i].page;
@@ -381,8 +381,6 @@ static int scsi_req_map_sg(struct reques
 			bytes = min_t(unsigned int, len, PAGE_SIZE - off);
 
 			if (!bio) {
-				int nr_vecs;
-
 				nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages);
 				nr_pages -= nr_vecs;
 
@@ -401,7 +399,7 @@ static int scsi_req_map_sg(struct reques
 				goto free_bios;
 			}
 
-			if (bio->bi_vcnt >= bio->bi_max_vecs) {
+			if (bio->bi_vcnt >= nr_vecs) {
 				err = scsi_merge_bio(rq, bio);
 				if (err) {
 					bio_endio(bio, bio->bi_size, 0);



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-08 22:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-08 22:52 [PATCH 11/10] fix leak in scsi_req_map_sg Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).