lkml.org 
[lkml]   [2018]   [Dec]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] infiniband: fix a missing check of nla_put
Date
nla_put() may fail. The fix adds a check for its return value, and
returns -EMSGSIZE if it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/infiniband/core/addr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 0dce94e3c495..32d033ebaa5b 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -178,7 +178,8 @@ 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))
+ return -EMSGSIZE;

/* Repair the nlmsg header length */
nlmsg_end(skb, nlh);
--
2.17.2 (Apple Git-113)
\
 
 \ /
  Last update: 2018-12-26 03:07    [W:0.069 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site