mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Qianqiang Liu <qianqiang.liu@163.com>
Cc: jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event
Date: Wed, 9 Oct 2024 17:30:00 +0300	[thread overview]
Message-ID: <a84a2fc3-33b6-46da-a1bd-3343fa07eaf9@stanley.mountain> (raw)
In-Reply-To: <20240926143402.70354-1-qianqiang.liu@163.com>

On Thu, Sep 26, 2024 at 10:34:03PM +0800, Qianqiang Liu wrote:
> nlmsg_put() may return a NULL pointer assigned to nlh, which will later
> be dereferenced in nlmsg_end().
> 
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> ---
>  drivers/infiniband/core/nldev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 39f89a4b8649..7dc8e2ec62cc 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -2816,6 +2816,8 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
>  	nlh = nlmsg_put(skb, 0, 0,
>  			RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR),
>  			0, 0);
> +	if (!nlh)
> +		goto err_free;

Need to set the error code before the goto.  "ret = -EMSGSIZE;"

regards,
dan carpenter


      parent reply	other threads:[~2024-10-09 14:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-26 14:34 Qianqiang Liu
2024-09-27 14:06 ` [PATCH v2] " Qianqiang Liu
2024-10-04 20:13   ` Jason Gunthorpe
2024-10-09 14:31     ` Dan Carpenter
2024-10-09 14:30 ` Dan Carpenter [this message]

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=a84a2fc3-33b6-46da-a1bd-3343fa07eaf9@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=qianqiang.liu@163.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

all inboxes | Powered by JetHome®