Use the block layer helper to validate block size instead of open coding it. Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx> --- drivers/block/nbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 1183f7872b71..3f58c3eb38b6 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -323,7 +323,8 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, { if (!blksize) blksize = 1u << NBD_DEF_BLKSIZE_BITS; - if (blksize < 512 || blksize > PAGE_SIZE || !is_power_of_2(blksize)) + + if (blk_validate_block_size(blksize)) return -EINVAL; nbd->config->bytesize = bytesize; -- 2.11.0