From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Evgeniy Polyakov <zbr@ioremap.net>
Cc: netdev@vger.kernel.org,
Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: [PATCH 1/1] connector: use nlmsg_put() instead of NLMSG_PUT() macro.
Date: Tue, 26 Jun 2012 17:41:24 +0200 [thread overview]
Message-ID: <1340725284-21698-1-git-send-email-javier.martinez@collabora.co.uk> (raw)
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>
---
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 a1f9364..a728d33 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)
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);
--
1.7.7.6
next reply other threads:[~2012-06-26 15:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 15:41 Javier Martinez Canillas [this message]
2012-06-27 4:14 ` [PATCH 1/1] connector: use nlmsg_put() instead of NLMSG_PUT() macro David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340725284-21698-1-git-send-email-javier.martinez@collabora.co.uk \
--to=javier.martinez@collabora.co.uk \
--cc=netdev@vger.kernel.org \
--cc=zbr@ioremap.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox