mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] RDMA/rtrs: fix potential resources leaks
@ 2020-06-19 13:10 Bo YU
  2020-06-19 13:16 ` Jinpu Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Bo YU @ 2020-06-19 13:10 UTC (permalink / raw)
  To: danil.kipnis, jinpu.wang, ledford, jgg; +Cc: linux-rdma, linux-kernel, tsu.yubo

Dev is returned from allocation function kzalloc but it does not
free it in out_err path.

Detected by CoverityScan, CID# 1464569: (Resource leak)

Fixes: c0894b3ea69d3("RDMA/rtrs: core: lib functions shared between client and server modules")
Signed-off-by: Bo YU <tsu.yubo@gmail.com>
---
 drivers/infiniband/ulp/rtrs/rtrs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
index ff1093d6e4bc..03bdab92fa49 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs.c
@@ -607,6 +607,7 @@ rtrs_ib_dev_find_or_add(struct ib_device *ib_dev,
 	else
 		kfree(dev);
 out_err:
+	kfree(dev);
 	return NULL;
 }
 EXPORT_SYMBOL(rtrs_ib_dev_find_or_add);
--
2.11.0


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

* Re: [PATCH -next] RDMA/rtrs: fix potential resources leaks
  2020-06-19 13:10 [PATCH -next] RDMA/rtrs: fix potential resources leaks Bo YU
@ 2020-06-19 13:16 ` Jinpu Wang
  2020-06-19 14:46   ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Jinpu Wang @ 2020-06-19 13:16 UTC (permalink / raw)
  To: Bo YU; +Cc: Danil Kipnis, ledford, Jason Gunthorpe, linux-rdma, linux-kernel

Hi, Bo,
On Fri, Jun 19, 2020 at 3:10 PM Bo YU <tsu.yubo@gmail.com> wrote:
>
> Dev is returned from allocation function kzalloc but it does not
> free it in out_err path.
If allocation failed, kzalloc return NULL, nothing to free.
>
> Detected by CoverityScan, CID# 1464569: (Resource leak)
>
> Fixes: c0894b3ea69d3("RDMA/rtrs: core: lib functions shared between client and server modules")
> Signed-off-by: Bo YU <tsu.yubo@gmail.com>
> ---
>  drivers/infiniband/ulp/rtrs/rtrs.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
> index ff1093d6e4bc..03bdab92fa49 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs.c
> @@ -607,6 +607,7 @@ rtrs_ib_dev_find_or_add(struct ib_device *ib_dev,
>         else
>                 kfree(dev);
>  out_err:
> +       kfree(dev);
>         return NULL;
>  }
>  EXPORT_SYMBOL(rtrs_ib_dev_find_or_add);
> --
> 2.11.0
>

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

* Re: [PATCH -next] RDMA/rtrs: fix potential resources leaks
  2020-06-19 13:16 ` Jinpu Wang
@ 2020-06-19 14:46   ` Jason Gunthorpe
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2020-06-19 14:46 UTC (permalink / raw)
  To: Jinpu Wang; +Cc: Bo YU, Danil Kipnis, ledford, linux-rdma, linux-kernel

On Fri, Jun 19, 2020 at 03:16:57PM +0200, Jinpu Wang wrote:
> Hi, Bo,
> On Fri, Jun 19, 2020 at 3:10 PM Bo YU <tsu.yubo@gmail.com> wrote:
> >
> > Dev is returned from allocation function kzalloc but it does not
> > free it in out_err path.
> If allocation failed, kzalloc return NULL, nothing to free.

You should re-organize this to not confuse coverity.

IS_ERR_OR_NULL should rarely be used and is the problem here

Jason

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

end of thread, other threads:[~2020-06-19 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19 13:10 [PATCH -next] RDMA/rtrs: fix potential resources leaks Bo YU
2020-06-19 13:16 ` Jinpu Wang
2020-06-19 14:46   ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®