block: nbd: fix sanity check for first_minor
Subsystems (2)
PATCH v2 1/1 block: nbd: fix sanity check for first_minor
From: "Yan, Zheng" <[email protected]>
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" <[email protected]>
--- drivers/block/nbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/nbd.c +2 -2
@@ -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; }
Signature · 1 line
2.12.2
Quoted 3 lines · Zheng
From: "Yan, Zheng" <[email protected]>
Device's minor is a 20-bits number, max value is
0xfffff.
I'd just drop this check again now that we do have proper error handling in add_disk.