Skip to contentSkip to conversation

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

PATCH Applied Guoqing Jiang 3 participants 4 messages Dec 30, 2022 – Jan 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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")

---
V2 changes:
1. add parentheses around ‘-’ per lkp

 drivers/block/rnbd/rnbd-clt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-clt.c +1 -1
index 78334da74d8b..5eb8c7855970 100644
@@ -1440,7 +1440,7 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
 		goto out_alloc;
 	}
 
-	ret = ida_alloc_max(&index_ida, 1 << (MINORBITS - RNBD_PART_BITS),
+	ret = ida_alloc_max(&index_ida, (1 << (MINORBITS - RNBD_PART_BITS)) - 1,
 			    GFP_KERNEL);
 	if (ret < 0) {
 		pr_err("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n",
Signature · 1 line
2.35.3
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 4 lines · Guoqing Jiang

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

Quoted 8 lines

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")
Quoted 23 lines

---
V2 changes:
1. add parentheses around ‘-’ per lkp

 drivers/block/rnbd/rnbd-clt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-clt.c +1 -2
index 78334da74d8b..5eb8c7855970 100644
@@ -1440,7 +1440,7 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
                goto out_alloc;
        }
 
-       ret = ida_alloc_max(&index_ida, 1 << (MINORBITS - RNBD_PART_BITS),
+       ret = ida_alloc_max(&index_ida, (1 << (MINORBITS - RNBD_PART_BITS)) - 1,
                            GFP_KERNEL);
        if (ret < 0) {
                pr_err("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n",
--

2.35.3

#2 lore raw
In reply to Guoqing Jiang

Hi Jens,

Could you pls merge this one?

Thanks,
Guoqing

Quoted 31 lines · Guoqing Jiang

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")

---
V2 changes:
1. add parentheses around ‘-’ per lkp

  drivers/block/rnbd/rnbd-clt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-clt.c +1 -1
index 78334da74d8b..5eb8c7855970 100644
@@ -1440,7 +1440,7 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
  		goto out_alloc;
  	}
 
-	ret = ida_alloc_max(&index_ida, 1 << (MINORBITS - RNBD_PART_BITS),
+	ret = ida_alloc_max(&index_ida, (1 << (MINORBITS - RNBD_PART_BITS)) - 1,
  			    GFP_KERNEL);
  	if (ret < 0) {
  		pr_err("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n",
maintainer Applied
#3 lore raw
In reply to Guoqing Jiang
Quoted 8 lines · Guoqing Jiang

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?

[...]

Applied, thanks!

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

      commit: 9d6033e350694a67885605674244d43c9559dc36

Best regards,

Signature · 1 line
Jens Axboe