From: Tejun Heo <tj@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: hunger <hunger@hunger.hu>, Emese Revfy <re.emese@gmail.com>,
PaX Team <pageexec@freemail.hu>,
linux-kernel@vger.kernel.org
Subject: [PATCH] block: don't call kobj_map() with 0 @range
Date: Wed, 5 Jun 2013 18:20:35 -0700 [thread overview]
Message-ID: <20130606012035.GQ10693@mtj.dyndns.org> (raw)
In-Reply-To: <20130605031520.GP14916@htj.dyndns.org>
When fully dynamic devt allocation is used, gendisk->minors is zero.
In such cases, add_disk() calls blk_register_region() with 0 @range
expecting it to do nothing; however, blk_register_region() is a thin
wrapper around kobj_map(), which doesn't expect 0 @range input and
goes through an underflow while calculating the number of mapping
entries to allocate. Fortunately, it has limit check built-in and
this doesn't lead to anything disastrous - it just wastes 255 *
sizeof(struct probe) bytes.
When gendisk->minors is zero, the kobj_map isn't used at all and both
blk_[un]register_region() are expected to be noops. Add conditionals
to blk_[un]register_region() so that nothing happens when @range is
zero.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: PaX Team <pageexec@freemail.hu>
Cc: stable@vger.kernel.org
---
block/genhd.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 20625ee..3a4a1ed 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
/*
* Register device numbers dev..(dev+range-1)
- * range must be nonzero
+ * Noop if @range is zero.
* The hash chain is sorted on range, so that subranges can override.
*/
void blk_register_region(dev_t devt, unsigned long range, struct module *module,
struct kobject *(*probe)(dev_t, int *, void *),
int (*lock)(dev_t, void *), void *data)
{
- kobj_map(bdev_map, devt, range, module, probe, lock, data);
+ if (range)
+ kobj_map(bdev_map, devt, range, module, probe, lock, data);
}
EXPORT_SYMBOL(blk_register_region);
+/* undo blk_register_region(), noop if @range is zero */
void blk_unregister_region(dev_t devt, unsigned long range)
{
- kobj_unmap(bdev_map, devt, range);
+ if (range)
+ kobj_unmap(bdev_map, devt, range);
}
EXPORT_SYMBOL(blk_unregister_region);
parent reply other threads:[~2013-06-06 1:20 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20130605031520.GP14916@htj.dyndns.org>]
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=20130606012035.GQ10693@mtj.dyndns.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=hunger@hunger.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=pageexec@freemail.hu \
--cc=re.emese@gmail.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 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®