Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block/rnbd-clt: fix wrong max ID in ida_alloc_max

We need to pass 'end - 1' to ida_alloc_max after switch from
ida_simple_get to ida_alloc_max.

Otherwise smatch warns.

drivers/block/rnbd/rnbd-clt.c:1460 init_dev() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?

Fixes: 24afc15dbe21 ("block/rnbd: Remove a useless mutex")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Link: https://lore.kernel.org/r/20221230010926.32243-1-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Guoqing Jiang and committed by
Jens Axboe
9d6033e3 e3ff8887

+1 -1
+1 -1
drivers/block/rnbd/rnbd-clt.c
··· 1440 1440 goto out_alloc; 1441 1441 } 1442 1442 1443 - ret = ida_alloc_max(&index_ida, 1 << (MINORBITS - RNBD_PART_BITS), 1443 + ret = ida_alloc_max(&index_ida, (1 << (MINORBITS - RNBD_PART_BITS)) - 1, 1444 1444 GFP_KERNEL); 1445 1445 if (ret < 0) { 1446 1446 pr_err("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n",