All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/sa: Fix memleak in ib_nl_make_request
@ 2020-12-20  8:13 Dinghao Liu
  2020-12-27  7:13 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2020-12-20  8:13 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Doug Ledford, Jason Gunthorpe, Gustavo A. R. Silva, Ursula Braun,
	Leon Romanovsky, Håkon Bugge, Divya Indi,
	Mauro Carvalho Chehab, linux-rdma, linux-kernel

When rdma_nl_multicast() fails, skb should be freed
just like when ibnl_put_msg() fails.

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

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 89a831fa1885..8bd23b5cc913 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -873,8 +873,10 @@ static int ib_nl_make_request(struct ib_sa_query *query, gfp_t gfp_mask)
 	spin_lock_irqsave(&ib_nl_request_lock, flags);
 	ret = rdma_nl_multicast(&init_net, skb, RDMA_NL_GROUP_LS, gfp_flag);
 
-	if (ret)
+	if (ret) {
+		nlmsg_free(skb);
 		goto out;
+	}
 
 	/* Put the request on the list.*/
 	delay = msecs_to_jiffies(sa_local_svc_timeout_ms);
-- 
2.17.1


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

* Re: [PATCH] IB/sa: Fix memleak in ib_nl_make_request
  2020-12-20  8:13 [PATCH] IB/sa: Fix memleak in ib_nl_make_request Dinghao Liu
@ 2020-12-27  7:13 ` Leon Romanovsky
  2020-12-28  3:07   ` dinghao.liu
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2020-12-27  7:13 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Doug Ledford, Jason Gunthorpe, Gustavo A. R. Silva,
	Ursula Braun, Håkon Bugge, Divya Indi,
	Mauro Carvalho Chehab, linux-rdma, linux-kernel

On Sun, Dec 20, 2020 at 04:13:14PM +0800, Dinghao Liu wrote:
> When rdma_nl_multicast() fails, skb should be freed
> just like when ibnl_put_msg() fails.

It is not so simple as you wrote in the description.

There are no other places in the linux kernel that free
SKBs after netlink_multicast() failure.

Thanks

>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/infiniband/core/sa_query.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index 89a831fa1885..8bd23b5cc913 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -873,8 +873,10 @@ static int ib_nl_make_request(struct ib_sa_query *query, gfp_t gfp_mask)
>  	spin_lock_irqsave(&ib_nl_request_lock, flags);
>  	ret = rdma_nl_multicast(&init_net, skb, RDMA_NL_GROUP_LS, gfp_flag);
>
> -	if (ret)
> +	if (ret) {
> +		nlmsg_free(skb);
>  		goto out;
> +	}
>
>  	/* Put the request on the list.*/
>  	delay = msecs_to_jiffies(sa_local_svc_timeout_ms);
> --
> 2.17.1
>

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

* Re: Re: [PATCH] IB/sa: Fix memleak in ib_nl_make_request
  2020-12-27  7:13 ` Leon Romanovsky
@ 2020-12-28  3:07   ` dinghao.liu
  0 siblings, 0 replies; 3+ messages in thread
From: dinghao.liu @ 2020-12-28  3:07 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: kjlu, Doug Ledford, Jason Gunthorpe, Gustavo A. R. Silva,
	Ursula Braun, Håkon Bugge, Divya Indi,
	Mauro Carvalho Chehab, linux-rdma, linux-kernel

> On Sun, Dec 20, 2020 at 04:13:14PM +0800, Dinghao Liu wrote:
> > When rdma_nl_multicast() fails, skb should be freed
> > just like when ibnl_put_msg() fails.
> 
> It is not so simple as you wrote in the description.
> 
> There are no other places in the linux kernel that free
> SKBs after netlink_multicast() failure.
> 

It's clear for me, thanks.

Regards,
Dinghao

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

end of thread, other threads:[~2020-12-28  3:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-20  8:13 [PATCH] IB/sa: Fix memleak in ib_nl_make_request Dinghao Liu
2020-12-27  7:13 ` Leon Romanovsky
2020-12-28  3:07   ` dinghao.liu

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.