From: Leon Romanovsky <leon@kernel.org>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Parav Pandit <parav@mellanox.com>,
Dennis Dalessandro <dennis.dalessandro@intel.com>,
Artemy Kovalyov <artemyko@mellanox.com>,
Alex Estrin <alex.estrin@intel.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] infiniband: add checks for the status of nla_put
Date: Wed, 26 Dec 2018 21:49:44 +0200 [thread overview]
Message-ID: <20181226194944.GI10329@mtr-leonro.mtl.com> (raw)
In-Reply-To: <20181226021141.71538-1-kjlu@umn.edu>
[-- Attachment #1: Type: text/plain, Size: 2902 bytes --]
On Tue, Dec 25, 2018 at 08:11:39PM -0600, Kangjie Lu wrote:
> The fix inserts multiple checks for nla_put, and issues warnings if it
> fails.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
I didn't look very close, but it strange that failure in nla_put()
doesn't follow by canceling of netlink message.
Plus extensive usage of pr_warn() is not needed here.
Thanks
> drivers/infiniband/core/sa_query.c | 39 ++++++++++++++++++------------
> 1 file changed, 24 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index be5ba5e15496..0e5d7a6dde36 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -775,28 +775,37 @@ static void ib_nl_set_path_rec_attrs(struct sk_buff *skb,
> /* Now build the attributes */
> if (comp_mask & IB_SA_PATH_REC_SERVICE_ID) {
> val64 = be64_to_cpu(sa_rec->service_id);
> - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SERVICE_ID,
> - sizeof(val64), &val64);
> + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SERVICE_ID,
> + sizeof(val64), &val64))
> + pr_warn("nla_put failed\n");
> + }
> + if (comp_mask & IB_SA_PATH_REC_DGID) {
> + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_DGID,
> + sizeof(sa_rec->dgid), &sa_rec->dgid))
> + pr_warn("nla_put failed\n");
> + }
> + if (comp_mask & IB_SA_PATH_REC_SGID) {
> + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SGID,
> + sizeof(sa_rec->sgid), &sa_rec->sgid))
> + pr_warn("nla_put failed\n");
> + }
> + if (comp_mask & IB_SA_PATH_REC_TRAFFIC_CLASS) {
> + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_TCLASS,
> + sizeof(sa_rec->traffic_class), &sa_rec->traffic_class))
> + pr_warn("nla_put failed\n");
> }
> - if (comp_mask & IB_SA_PATH_REC_DGID)
> - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_DGID,
> - sizeof(sa_rec->dgid), &sa_rec->dgid);
> - if (comp_mask & IB_SA_PATH_REC_SGID)
> - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SGID,
> - sizeof(sa_rec->sgid), &sa_rec->sgid);
> - if (comp_mask & IB_SA_PATH_REC_TRAFFIC_CLASS)
> - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_TCLASS,
> - sizeof(sa_rec->traffic_class), &sa_rec->traffic_class);
>
> if (comp_mask & IB_SA_PATH_REC_PKEY) {
> val16 = be16_to_cpu(sa_rec->pkey);
> - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_PKEY,
> - sizeof(val16), &val16);
> + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_PKEY,
> + sizeof(val16), &val16))
> + pr_warn("nla_put failed\n");
> }
> if (comp_mask & IB_SA_PATH_REC_QOS_CLASS) {
> val16 = be16_to_cpu(sa_rec->qos_class);
> - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_QOS_CLASS,
> - sizeof(val16), &val16);
> + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_QOS_CLASS,
> + sizeof(val16), &val16))
> + pr_warn("nla_put failed\n");
> }
> }
>
> --
> 2.17.2 (Apple Git-113)
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
prev parent reply other threads:[~2018-12-26 19:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 2:11 [PATCH] infiniband: add checks for the status of nla_put Kangjie Lu
2018-12-26 19:49 ` 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=20181226194944.GI10329@mtr-leonro.mtl.com \
--to=leon@kernel.org \
--cc=alex.estrin@intel.com \
--cc=artemyko@mellanox.com \
--cc=dennis.dalessandro@intel.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