All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max
@ 2022-12-30  1:09 Guoqing Jiang
  2023-01-02 11:46 ` Jinpu Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guoqing Jiang @ 2022-12-30  1:09 UTC (permalink / raw)
  To: haris.iqbal, jinpu.wang, axboe, christophe.jaillet; +Cc: linux-block

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>
---
V2 changes:
1. add parentheses around ‘-’ per lkp

 drivers/block/rnbd/rnbd-clt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 78334da74d8b..5eb8c7855970 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max
  2022-12-30  1:09 [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max Guoqing Jiang
@ 2023-01-02 11:46 ` Jinpu Wang
  2023-01-17 13:30 ` Guoqing Jiang
  2023-01-17 15:33 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jinpu Wang @ 2023-01-02 11:46 UTC (permalink / raw)
  To: Guoqing Jiang; +Cc: haris.iqbal, axboe, christophe.jaillet, linux-block

On Fri, Dec 30, 2022 at 2:09 AM Guoqing Jiang <guoqing.jiang@linux.dev> wrote:
>
> 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>
> ---
> V2 changes:
> 1. add parentheses around ‘-’ per lkp
>
>  drivers/block/rnbd/rnbd-clt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
> index 78334da74d8b..5eb8c7855970 100644
> --- a/drivers/block/rnbd/rnbd-clt.c
> +++ b/drivers/block/rnbd/rnbd-clt.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max
  2022-12-30  1:09 [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max Guoqing Jiang
  2023-01-02 11:46 ` Jinpu Wang
@ 2023-01-17 13:30 ` Guoqing Jiang
  2023-01-17 15:33 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Guoqing Jiang @ 2023-01-17 13:30 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, haris.iqbal, christophe.jaillet, jinpu.wang

Hi Jens,

Could you pls merge this one?

Thanks,
Guoqing

On 12/30/22 09:09, Guoqing Jiang wrote:
> 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>
> ---
> V2 changes:
> 1. add parentheses around ‘-’ per lkp
>
>   drivers/block/rnbd/rnbd-clt.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
> index 78334da74d8b..5eb8c7855970 100644
> --- a/drivers/block/rnbd/rnbd-clt.c
> +++ b/drivers/block/rnbd/rnbd-clt.c
> @@ -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",


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max
  2022-12-30  1:09 [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max Guoqing Jiang
  2023-01-02 11:46 ` Jinpu Wang
  2023-01-17 13:30 ` Guoqing Jiang
@ 2023-01-17 15:33 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2023-01-17 15:33 UTC (permalink / raw)
  To: haris.iqbal, jinpu.wang, christophe.jaillet, Guoqing Jiang; +Cc: linux-block


On Fri, 30 Dec 2022 09:09:26 +0800, Guoqing Jiang wrote:
> 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,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-17 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-30  1:09 [PATCH V2] block/rnbd-clt: fix wrong max ID in ida_alloc_max Guoqing Jiang
2023-01-02 11:46 ` Jinpu Wang
2023-01-17 13:30 ` Guoqing Jiang
2023-01-17 15:33 ` Jens Axboe

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.