mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xen.org>, <linux-kernel@vger.kernel.org>
Cc: Roger Pau Monne <roger.pau@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 3/4] xen-blkback: check the number of iovecs before allocating a bios
Date: Fri, 21 Jun 2013 12:56:55 +0200	[thread overview]
Message-ID: <1371812216-17093-4-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1371812216-17093-1-git-send-email-roger.pau@citrix.com>

With the introduction of indirect segments we can receive requests
with a number of segments bigger than the maximum number of allowed
iovecs in a bios, so make sure that blkback doesn't try to allocate a
bios with more iovecs than BIO_MAX_PAGES

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 drivers/block/xen-blkback/blkback.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index d622d86..876116b 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -1236,7 +1236,8 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
 				     seg[i].nsec << 9,
 				     seg[i].offset) == 0)) {
 
-			bio = bio_alloc(GFP_KERNEL, nseg-i);
+			int nr_iovecs = (nseg-i) > BIO_MAX_PAGES ? BIO_MAX_PAGES : (nseg-i);
+			bio = bio_alloc(GFP_KERNEL, nr_iovecs);
 			if (unlikely(bio == NULL))
 				goto fail_put_bio;
 
-- 
1.7.7.5 (Apple Git-26)


  parent reply	other threads:[~2013-06-21 10:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21 10:56 [PATCH 0/4] xen-block: bug fixes for indirect-descriptors Roger Pau Monne
2013-06-21 10:56 ` [PATCH 1/4] xen-blkback: workaround compiler bug in gcc 4.1 Roger Pau Monne
2013-06-21 10:56 ` [PATCH 2/4] xen-blkfront: set blk_queue_max_hw_sectors correctly Roger Pau Monne
2013-06-21 10:56 ` Roger Pau Monne [this message]
2013-06-21 11:46   ` [Xen-devel] [PATCH 3/4] xen-blkback: check the number of iovecs before allocating a bios Jan Beulich
2013-06-21 12:02     ` Roger Pau Monné
2013-06-22  7:59   ` [PATCH v2 " Roger Pau Monne
2013-06-24 13:28     ` Konrad Rzeszutek Wilk
2013-06-25  8:03       ` Roger Pau Monné
2013-06-21 10:56 ` [PATCH 4/4] xen-blkfront: increase the default number of indirect segments Roger Pau Monne
2013-06-21 11:49   ` [Xen-devel] " Jan Beulich

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=1371812216-17093-4-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xen.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

all inboxes | Powered by JetHome®