From: "André Almeida" <andrealmeid@collabora.com>
To: linux-block@vger.kernel.org, linux-doc@vger.kernel.org
Cc: corbet@lwn.net, axboe@kernel.dk, m@bjorling.me,
kernel@collabora.com, krisman@collabora.com,
"André Almeida" <andrealmeid@collabora.com>
Subject: [PATCH 3/3] null_blk: validated the number of devices
Date: Wed, 11 Sep 2019 11:46:36 -0300 [thread overview]
Message-ID: <20190911144636.226945-3-andrealmeid@collabora.com> (raw)
In-Reply-To: <20190911144636.226945-1-andrealmeid@collabora.com>
There is no sense defining a negative number of devices, so change the type
to unsigned. If the number of devices is 0, it is impossible to the
userspace interact with the module, so there is no reasoning in loading
it.
Signed-off-by: André Almeida <andrealmeid@collabora.com>
---
drivers/block/null_blk_main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 7bc553ff7407..ab4b87677139 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -141,7 +141,7 @@ static int g_bs = 512;
module_param_named(bs, g_bs, int, 0444);
MODULE_PARM_DESC(bs, "Block size (in bytes)");
-static int nr_devices = 1;
+static unsigned int nr_devices = 1;
module_param(nr_devices, int, 0444);
MODULE_PARM_DESC(nr_devices, "Number of devices to register");
@@ -1758,6 +1758,10 @@ static int __init null_init(void)
pr_err("null_blk: legacy IO path no longer available\n");
return -EINVAL;
}
+ if (!nr_devices) {
+ pr_err("null_blk: invalid number of devices\n");
+ return -EINVAL;
+ }
if (g_queue_mode == NULL_Q_MQ && g_use_per_node_hctx) {
if (g_submit_queues != nr_online_nodes) {
pr_warn("null_blk: submit_queues param is set to %u.\n",
--
2.23.0
next prev parent reply other threads:[~2019-09-11 14:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 14:46 [PATCH 1/3] docs: block: null_blk: enhance document style André Almeida
2019-09-11 14:46 ` [PATCH 2/3] null_blk: fix module name at log message André Almeida
2019-09-12 15:47 ` Ezequiel Garcia
2019-09-12 20:47 ` Jens Axboe
2019-09-12 22:08 ` André Almeida
2019-09-11 14:46 ` André Almeida [this message]
2019-09-12 16:19 ` [PATCH 3/3] null_blk: validated the number of devices Matthew Wilcox
2019-09-12 22:07 ` André Almeida
2019-09-12 22:20 ` Chaitanya Kulkarni
2019-09-13 14:57 ` André Almeida
2019-09-13 15:12 ` Matthew Wilcox
2019-09-13 15:39 ` André Almeida
2019-09-13 16:23 ` Jens Axboe
2019-09-13 16:27 ` Chaitanya Kulkarni
2019-09-13 16:48 ` Jens Axboe
2019-09-11 22:05 ` [PATCH 1/3] docs: block: null_blk: enhance document style Jens Axboe
2019-09-11 22:26 ` André Almeida
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=20190911144636.226945-3-andrealmeid@collabora.com \
--to=andrealmeid@collabora.com \
--cc=axboe@kernel.dk \
--cc=corbet@lwn.net \
--cc=kernel@collabora.com \
--cc=krisman@collabora.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=m@bjorling.me \
/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).