Commit 85c93166 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by David S. Miller

connector: use nlmsg_put() instead of NLMSG_PUT() macro.

The NLMSG_PUT() macro contains a hidden goto which makes the code hard
to audit and very error prone.

While been there also use the inline function nlmsg_data() instead of the
NLMSG_DATA() macro to do explicit type checking.
Signed-off-by: default avatarJavier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a9fbcc6
...@@ -101,19 +101,19 @@ int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask) ...@@ -101,19 +101,19 @@ int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
nlh = NLMSG_PUT(skb, 0, msg->seq, NLMSG_DONE, size - sizeof(*nlh)); nlh = nlmsg_put(skb, 0, msg->seq, NLMSG_DONE, size - sizeof(*nlh), 0);
if (!nlh) {
kfree_skb(skb);
return -EMSGSIZE;
}
data = NLMSG_DATA(nlh); data = nlmsg_data(nlh);
memcpy(data, msg, sizeof(*data) + msg->len); memcpy(data, msg, sizeof(*data) + msg->len);
NETLINK_CB(skb).dst_group = group; NETLINK_CB(skb).dst_group = group;
return netlink_broadcast(dev->nls, skb, 0, group, gfp_mask); return netlink_broadcast(dev->nls, skb, 0, group, gfp_mask);
nlmsg_failure:
kfree_skb(skb);
return -EINVAL;
} }
EXPORT_SYMBOL_GPL(cn_netlink_send); EXPORT_SYMBOL_GPL(cn_netlink_send);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment