Skip to content

Commit

Permalink
connector: use nlmsg_put() instead of NLMSG_PUT() macro.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Javier Martinez Canillas authored and davem330 committed Jun 27, 2012
1 parent 4a9fbcc commit 85c9316
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/connector/connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
if (!skb)
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);

NETLINK_CB(skb).dst_group = group;

return netlink_broadcast(dev->nls, skb, 0, group, gfp_mask);

nlmsg_failure:
kfree_skb(skb);
return -EINVAL;
}
EXPORT_SYMBOL_GPL(cn_netlink_send);

Expand Down

0 comments on commit 85c9316

Please sign in to comment.