linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IB/uverbs: Fix memleak in ib_uverbs_add_one
@ 2020-08-21  8:10 Dinghao Liu
  2020-08-21  9:47 ` Håkon Bugge
  0 siblings, 1 reply; 4+ messages in thread
From: Dinghao Liu @ 2020-08-21  8:10 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Doug Ledford, Jason Gunthorpe, Yishai Hadas, Leon Romanovsky,
	Michel Lespinasse, Ariel Elior, Michal Kalderon, linux-rdma,
	linux-kernel

When ida_alloc_max() fails, uverbs_dev should be freed
just like when init_srcu_struct() fails. It's the same
for the error paths after this call.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/infiniband/core/uverbs_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 37794d88b1f3..c6b4e3e2aff6 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -1170,6 +1170,7 @@ static int ib_uverbs_add_one(struct ib_device *device)
 		ib_uverbs_comp_dev(uverbs_dev);
 	wait_for_completion(&uverbs_dev->comp);
 	put_device(&uverbs_dev->dev);
+	kfree(uverbs_dev);
 	return ret;
 }
 
-- 
2.17.1


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

* Re: [PATCH] IB/uverbs: Fix memleak in ib_uverbs_add_one
  2020-08-21  8:10 [PATCH] IB/uverbs: Fix memleak in ib_uverbs_add_one Dinghao Liu
@ 2020-08-21  9:47 ` Håkon Bugge
  2020-08-21 13:39   ` Jason Gunthorpe
  2020-08-22  5:58   ` dinghao.liu
  0 siblings, 2 replies; 4+ messages in thread
From: Håkon Bugge @ 2020-08-21  9:47 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Doug Ledford, Jason Gunthorpe, Yishai Hadas,
	Leon Romanovsky, Michel Lespinasse, Ariel Elior, Michal Kalderon,
	OFED mailing list, linux-kernel



> On 21 Aug 2020, at 10:10, Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
> 
> When ida_alloc_max() fails, uverbs_dev should be freed
> just like when init_srcu_struct() fails. It's the same
> for the error paths after this call.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/infiniband/core/uverbs_main.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> index 37794d88b1f3..c6b4e3e2aff6 100644
> --- a/drivers/infiniband/core/uverbs_main.c
> +++ b/drivers/infiniband/core/uverbs_main.c
> @@ -1170,6 +1170,7 @@ static int ib_uverbs_add_one(struct ib_device *device)
> 		ib_uverbs_comp_dev(uverbs_dev);
> 	wait_for_completion(&uverbs_dev->comp);
> 	put_device(&uverbs_dev->dev);
> +	kfree(uverbs_dev);

Isn't this taken care of by the *release* function pointer, which happens to be ib_uverbs_release_dev() ?


Thxs, Håkon

> 	return ret;
> }
> 
> -- 
> 2.17.1
> 


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

* Re: [PATCH] IB/uverbs: Fix memleak in ib_uverbs_add_one
  2020-08-21  9:47 ` Håkon Bugge
@ 2020-08-21 13:39   ` Jason Gunthorpe
  2020-08-22  5:58   ` dinghao.liu
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2020-08-21 13:39 UTC (permalink / raw)
  To: Håkon Bugge
  Cc: Dinghao Liu, kjlu, Doug Ledford, Yishai Hadas, Leon Romanovsky,
	Michel Lespinasse, Ariel Elior, Michal Kalderon,
	OFED mailing list, linux-kernel

On Fri, Aug 21, 2020 at 11:47:32AM +0200, Håkon Bugge wrote:
> 
> 
> > On 21 Aug 2020, at 10:10, Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
> > 
> > When ida_alloc_max() fails, uverbs_dev should be freed
> > just like when init_srcu_struct() fails. It's the same
> > for the error paths after this call.
> > 
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > drivers/infiniband/core/uverbs_main.c | 1 +
> > 1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> > index 37794d88b1f3..c6b4e3e2aff6 100644
> > +++ b/drivers/infiniband/core/uverbs_main.c
> > @@ -1170,6 +1170,7 @@ static int ib_uverbs_add_one(struct ib_device *device)
> > 		ib_uverbs_comp_dev(uverbs_dev);
> > 	wait_for_completion(&uverbs_dev->comp);
> > 	put_device(&uverbs_dev->dev);
> > +	kfree(uverbs_dev);
> 
> Isn't this taken care of by the *release* function pointer, which
> happens to be ib_uverbs_release_dev() ?

Yep

Jason

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

* Re: Re: [PATCH] IB/uverbs: Fix memleak in ib_uverbs_add_one
  2020-08-21  9:47 ` Håkon Bugge
  2020-08-21 13:39   ` Jason Gunthorpe
@ 2020-08-22  5:58   ` dinghao.liu
  1 sibling, 0 replies; 4+ messages in thread
From: dinghao.liu @ 2020-08-22  5:58 UTC (permalink / raw)
  To: Håkon Bugge
  Cc: kjlu, Doug Ledford, Jason Gunthorpe, Yishai Hadas,
	Leon Romanovsky, Michel Lespinasse, Ariel Elior, Michal Kalderon,
	OFED mailing list, linux-kernel

> 
> > On 21 Aug 2020, at 10:10, Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
> > 
> > When ida_alloc_max() fails, uverbs_dev should be freed
> > just like when init_srcu_struct() fails. It's the same
> > for the error paths after this call.
> > 
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> > drivers/infiniband/core/uverbs_main.c | 1 +
> > 1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> > index 37794d88b1f3..c6b4e3e2aff6 100644
> > --- a/drivers/infiniband/core/uverbs_main.c
> > +++ b/drivers/infiniband/core/uverbs_main.c
> > @@ -1170,6 +1170,7 @@ static int ib_uverbs_add_one(struct ib_device *device)
> > 		ib_uverbs_comp_dev(uverbs_dev);
> > 	wait_for_completion(&uverbs_dev->comp);
> > 	put_device(&uverbs_dev->dev);
> > +	kfree(uverbs_dev);
> 
> Isn't this taken care of by the *release* function pointer, which happens to be ib_uverbs_release_dev() ?
> 

You are right, thank you for pointing out that!

Regards,
Dinghao

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

end of thread, other threads:[~2020-08-22  5:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21  8:10 [PATCH] IB/uverbs: Fix memleak in ib_uverbs_add_one Dinghao Liu
2020-08-21  9:47 ` Håkon Bugge
2020-08-21 13:39   ` Jason Gunthorpe
2020-08-22  5:58   ` dinghao.liu

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