linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Jens Axboe <axboe@suse.de>, linux-scsi@vger.kernel.org
Subject: [PATCH 11/10] fix leak in scsi_req_map_sg
Date: Tue, 08 Nov 2005 16:52:26 -0600	[thread overview]
Message-ID: <1131490346.3787.2.camel@max> (raw)

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);



                 reply	other threads:[~2005-11-08 22:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1131490346.3787.2.camel@max \
    --to=michaelc@cs.wisc.edu \
    --cc=axboe@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).