From: Sumit Narayan <sumnaray@gmail.com>
To: linux-lvm@redhat.com
Subject: [linux-lvm] Function clone_bio
Date: Wed, 28 Nov 2007 10:25:57 -0500 [thread overview]
Message-ID: <474D8885.4090108@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 716 bytes --]
static struct bio *clone_bio(struct bio *bio, sector_t sector,
unsigned short idx, unsigned short bv_count,
unsigned int len, struct bio_set *bs)
{
struct bio *clone;
clone = bio_alloc_bioset(GFP_NOIO, bio->bi_max_vecs, bs);
__bio_clone(clone, bio);
clone->bi_destructor = dm_bio_destructor;
clone->bi_sector = sector;
clone->bi_idx = idx;
clone->bi_vcnt = idx + bv_count;
clone->bi_size = to_bytes(len);
clone->bi_flags &= ~(1 << BIO_SEG_VALID);
return clone;
}
There is a possibility of NULL being returned from bio_alloc_bioset.
Although unlikely, it could crash the kernel.
If required, I have attached a patch (created on linux-2.6.23.9).
--Sumit
[-- Attachment #2: dm-dm_c-fix.patch --]
[-- Type: text/x-patch, Size: 512 bytes --]
diff -uNr linux-2.6.23.9/drivers/md/dm.c linux-2.6.23.9-new/drivers/md/dm.c
--- linux-2.6.23.9/drivers/md/dm.c 2007-11-26 12:51:43.000000000 -0500
+++ linux-2.6.23.9-new/drivers/md/dm.c 2007-11-28 10:07:20.376734456 -0500
@@ -652,6 +652,13 @@
struct bio *clone;
clone = bio_alloc_bioset(GFP_NOIO, bio->bi_max_vecs, bs);
+
+ /*
+ * bio_alloc_bioset could return NULL.
+ */
+ if(!clone)
+ return clone;
+
__bio_clone(clone, bio);
clone->bi_destructor = dm_bio_destructor;
clone->bi_sector = sector;
next reply other threads:[~2007-11-28 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-28 15:25 Sumit Narayan [this message]
2007-11-28 18:50 ` [linux-lvm] Function clone_bio Alasdair G Kergon
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=474D8885.4090108@gmail.com \
--to=sumnaray@gmail.com \
--cc=linux-lvm@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.