summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2016-10-26 10:53:16 +0200
committerDavid S. Miller <davem@davemloft.net>2016-10-29 14:57:42 -0400
commitb15ca182ed136087f6a2cb9ffe880c923f36a56e (patch)
tree9f5b9829fdeb6491eae3c19d92a1a3a80e19f31d /include
parentf8da977989c5d5d2f38e025d4ac1e18243723dbb (diff)
netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
Wrap several common instances of: kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL); Signed-off-by: Thomas Graf <tgraf@suug.ch> Acked-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/netlink.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 254a0fc01800..a34f53acb6d6 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -1191,6 +1191,16 @@ static inline struct in6_addr nla_get_in6_addr(const struct nlattr *nla)
}
/**
+ * nla_memdup - duplicate attribute memory (kmemdup)
+ * @src: netlink attribute to duplicate from
+ * @gfp: GFP mask
+ */
+static inline void *nla_memdup(const struct nlattr *src, gfp_t gfp)
+{
+ return kmemdup(nla_data(src), nla_len(src), gfp);
+}
+
+/**
* nla_nest_start - Start a new level of nested attributes
* @skb: socket buffer to add attributes to
* @attrtype: attribute type of container