diff options
author | Javier Martinez Canillas <javier.martinez@collabora.co.uk> | 2012-06-26 01:41:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-27 00:14:20 -0400 |
commit | 85c931665d822f1bedd69ecaab09a8ba84643020 (patch) | |
tree | dfa309a0e71fb29912465a239d5fef386ab18391 /drivers/connector | |
parent | 4a9fbcc6d606ae7f6a4e65b8a2759f46be8d45c6 (diff) |
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: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/connector')
-rw-r--r-- | drivers/connector/connector.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c index dde6a0fad408..34e0e9e4d913 100644 --- a/drivers/connector/connector.c +++ b/drivers/connector/connector.c | |||
@@ -101,19 +101,19 @@ int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask) | |||
101 | if (!skb) | 101 | if (!skb) |
102 | return -ENOMEM; | 102 | return -ENOMEM; |
103 | 103 | ||
104 | nlh = NLMSG_PUT(skb, 0, msg->seq, NLMSG_DONE, size - sizeof(*nlh)); | 104 | nlh = nlmsg_put(skb, 0, msg->seq, NLMSG_DONE, size - sizeof(*nlh), 0); |
105 | if (!nlh) { | ||
106 | kfree_skb(skb); | ||
107 | return -EMSGSIZE; | ||
108 | } | ||
105 | 109 | ||
106 | data = NLMSG_DATA(nlh); | 110 | data = nlmsg_data(nlh); |
107 | 111 | ||
108 | memcpy(data, msg, sizeof(*data) + msg->len); | 112 | memcpy(data, msg, sizeof(*data) + msg->len); |
109 | 113 | ||
110 | NETLINK_CB(skb).dst_group = group; | 114 | NETLINK_CB(skb).dst_group = group; |
111 | 115 | ||
112 | return netlink_broadcast(dev->nls, skb, 0, group, gfp_mask); | 116 | return netlink_broadcast(dev->nls, skb, 0, group, gfp_mask); |
113 | |||
114 | nlmsg_failure: | ||
115 | kfree_skb(skb); | ||
116 | return -EINVAL; | ||
117 | } | 117 | } |
118 | EXPORT_SYMBOL_GPL(cn_netlink_send); | 118 | EXPORT_SYMBOL_GPL(cn_netlink_send); |
119 | 119 | ||