From: "Yan, Zheng" <ukernel@gmail.com>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: axboe@kernel.dk, hch@lst.de, paskripkin@gmail.com, "Yan,
Zheng" <yanzheng03@kuaishou.com>
Subject: [PATCH v2] block: nbd: fix sanity check for first_minor
Date: Mon, 11 Oct 2021 10:45:09 +0800 [thread overview]
Message-ID: <20211011024509.2012-1-ukernel@gmail.com> (raw)
From: "Yan, Zheng" <yanzheng03@kuaishou.com>
Device's minor is a 20-bits number, max value is 0xfffff.
Fixes: b1a811633f ("block: nbd: add sanity check for first_minor").
Signed-off-by: "Yan, Zheng" <yanzheng03@kuaishou.com>
---
drivers/block/nbd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 1183f7872b71..118039d35468 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1750,10 +1750,10 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
/* Too big first_minor can cause duplicate creation of
* sysfs files/links, since first_minor will be truncated to
- * byte in __device_add_disk().
+ * 20-bits number in __device_add_disk().
*/
disk->first_minor = index << part_shift;
- if (disk->first_minor > 0xff) {
+ if (disk->first_minor > MINORMASK) {
err = -EINVAL;
goto out_free_idr;
}
--
2.12.2
next reply other threads:[~2021-10-11 2:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 2:45 Yan, Zheng [this message]
2021-10-11 7:35 ` [PATCH v2] block: nbd: fix sanity check for first_minor Christoph Hellwig
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=20211011024509.2012-1-ukernel@gmail.com \
--to=ukernel@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paskripkin@gmail.com \
--cc=yanzheng03@kuaishou.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.