nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvdimm: Call ida_simple_remove() when failed
@ 2022-08-10  6:07 Bo Liu
  2022-09-20 17:32 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Bo Liu @ 2022-08-10  6:07 UTC (permalink / raw)
  To: dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny
  Cc: nvdimm, linux-kernel, Bo Liu

In function nvdimm_bus_register(), when code execution fails, we should
call ida_simple_remove() to free ida.

Signed-off-by: Bo Liu <liubo03@inspur.com>
---
 drivers/nvdimm/bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index b38d0355b0ac..3415dc62632b 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -371,6 +371,7 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
 	return nvdimm_bus;
  err:
 	put_device(&nvdimm_bus->dev);
+	ida_simple_remove(&nd_ida, nvdimm_bus->id);
 	return NULL;
 }
 EXPORT_SYMBOL_GPL(nvdimm_bus_register);
-- 
2.27.0


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

* RE: [PATCH] nvdimm: Call ida_simple_remove() when failed
  2022-08-10  6:07 [PATCH] nvdimm: Call ida_simple_remove() when failed Bo Liu
@ 2022-09-20 17:32 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2022-09-20 17:32 UTC (permalink / raw)
  To: Bo Liu, dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny
  Cc: nvdimm, linux-kernel, Bo Liu

Bo Liu wrote:
> In function nvdimm_bus_register(), when code execution fails, we should
> call ida_simple_remove() to free ida.
> 
> Signed-off-by: Bo Liu <liubo03@inspur.com>
> ---
>  drivers/nvdimm/bus.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> index b38d0355b0ac..3415dc62632b 100644
> --- a/drivers/nvdimm/bus.c
> +++ b/drivers/nvdimm/bus.c
> @@ -371,6 +371,7 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
>  	return nvdimm_bus;
>   err:
>  	put_device(&nvdimm_bus->dev);
> +	ida_simple_remove(&nd_ida, nvdimm_bus->id);

No, this is a double-free. The put_device() will trigger
nvdimm_bus_release().

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

end of thread, other threads:[~2022-09-20 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10  6:07 [PATCH] nvdimm: Call ida_simple_remove() when failed Bo Liu
2022-09-20 17:32 ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).