Skip to contentSkip to conversation

infiniband: fix a missing check of nla_put

PATCH In review Kangjie Lu 2 participants 2 messages Dec 26, 2018 InfiniBand

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 infiniband: fix a missing check of nla_put

nla_put() may fail. The fix adds a check for its return value, and returns -EMSGSIZE if it fails.

---
 drivers/infiniband/core/addr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/addr.c +2 -1
index 0dce94e3c495..32d033ebaa5b 100644
@@ -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);
Signature · 1 line
2.17.2 (Apple Git-113)
#1 lore raw
Quoted 7 lines · Kangjie Lu

nla_put() may fail. The fix adds a check for its return value, and returns -EMSGSIZE if it fails.

---
 drivers/infiniband/core/addr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

The same comment as on previous patch, lack of netlink cancel.

Thanks

Quoted 18 lines
drivers/infiniband/core/addr.c +2 -2
index 0dce94e3c495..32d033ebaa5b 100644
@@ -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)