linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [V2] infiniband: fix a missing check of nla_put
@ 2019-01-05 16:18 Aditya Pakki
  2019-01-14 21:04 ` Jason Gunthorpe
  2019-01-15 18:14 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Aditya Pakki @ 2019-01-05 16:18 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Doug Ledford, Jason Gunthorpe, Leon Romanovsky,
	Parav Pandit, Daniel Jurgens, linux-rdma, linux-kernel

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);
+		return -EMSGSIZE;
+	}
 
 	/* Repair the nlmsg header length */
 	nlmsg_end(skb, nlh);
-- 
2.17.1


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

end of thread, other threads:[~2019-01-15 18:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).