public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Parav Pandit <parav@mellanox.com>,
	Daniel Jurgens <danielj@mellanox.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [V2] infiniband: fix a missing check of nla_put
Date: Tue, 15 Jan 2019 20:14:29 +0200	[thread overview]
Message-ID: <20190115181429.GP15600@mtr-leonro.mtl.com> (raw)
In-Reply-To: <20190105161808.3496-1-pakki001@umn.edu>

[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]

On Sat, Jan 05, 2019 at 10:18:07AM -0600, Aditya Pakki wrote:
> nla_put() may fail. The fix adds a check for its return value, and
> returns -EMSGSIZE if it fails, post canceling netlink msg.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/infiniband/core/addr.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
> index 0dce94e3c495..e847b34bacd1 100644
> --- a/drivers/infiniband/core/addr.c
> +++ b/drivers/infiniband/core/addr.c
> @@ -178,7 +178,10 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr,
>  	/* Construct the family header first */
>  	header = skb_put(skb, NLMSG_ALIGN(sizeof(*header)));
>  	header->ifindex = dev_addr->bound_dev_if;
> -	nla_put(skb, attrtype, size, daddr);
> +	if (nla_put(skb, attrtype, size, daddr)) {
> +		nlmsg_cancel(skb, nlh);

It should be nlmsg_free() and not nlmsg_cancel()

> +		return -EMSGSIZE;
> +	}
>
>  	/* Repair the nlmsg header length */
>  	nlmsg_end(skb, nlh);
> --
> 2.17.1
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

      parent reply	other threads:[~2019-01-15 18:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05 16:18 [PATCH] [V2] infiniband: fix a missing check of nla_put Aditya Pakki
2019-01-14 21:04 ` Jason Gunthorpe
2019-01-15 18:14 ` Leon Romanovsky [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=20190115181429.GP15600@mtr-leonro.mtl.com \
    --to=leon@kernel.org \
    --cc=danielj@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --cc=parav@mellanox.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