public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: kjlu@umn.edu, "Doug Ledford" <dledford@redhat.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	"Ursula Braun" <ubraun@linux.ibm.com>,
	"Håkon Bugge" <haakon.bugge@oracle.com>,
	"Divya Indi" <divya.indi@oracle.com>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] IB/sa: Fix memleak in ib_nl_make_request
Date: Sun, 27 Dec 2020 09:13:46 +0200	[thread overview]
Message-ID: <20201227071346.GB4457@unreal> (raw)
In-Reply-To: <20201220081317.18728-1-dinghao.liu@zju.edu.cn>

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
>

  reply	other threads:[~2020-12-27  7:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20  8:13 [PATCH] IB/sa: Fix memleak in ib_nl_make_request Dinghao Liu
2020-12-27  7:13 ` Leon Romanovsky [this message]
2020-12-28  3:07   ` dinghao.liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201227071346.GB4457@unreal \
    --to=leon@kernel.org \
    --cc=dinghao.liu@zju.edu.cn \
    --cc=divya.indi@oracle.com \
    --cc=dledford@redhat.com \
    --cc=gustavoars@kernel.org \
    --cc=haakon.bugge@oracle.com \
    --cc=jgg@ziepe.ca \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=ubraun@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox