Commit c6c08614 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net: tipc: allocate attrs locally instead of using genl_family_attrbuf in compat_dumpit()

As this is the last user of genl_family_attrbuf, convert to allocate
attrs locally and do it in a similar way this is done in compat_doit().
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 057af707
...@@ -271,18 +271,6 @@ struct genl_family tipc_genl_family __ro_after_init = { ...@@ -271,18 +271,6 @@ struct genl_family tipc_genl_family __ro_after_init = {
.n_ops = ARRAY_SIZE(tipc_genl_v2_ops), .n_ops = ARRAY_SIZE(tipc_genl_v2_ops),
}; };
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)
{
u32 maxattr = tipc_genl_family.maxattr;
*attr = genl_family_attrbuf(&tipc_genl_family);
if (!*attr)
return -EOPNOTSUPP;
return nlmsg_parse_deprecated(nlh, GENL_HDRLEN, *attr, maxattr,
tipc_nl_policy, NULL);
}
int __init tipc_netlink_start(void) int __init tipc_netlink_start(void)
{ {
int res; int res;
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <net/netlink.h> #include <net/netlink.h>
extern struct genl_family tipc_genl_family; extern struct genl_family tipc_genl_family;
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***buf);
struct tipc_nl_msg { struct tipc_nl_msg {
struct sk_buff *skb; struct sk_buff *skb;
......
...@@ -186,6 +186,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, ...@@ -186,6 +186,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
struct sk_buff *buf; struct sk_buff *buf;
struct nlmsghdr *nlmsg; struct nlmsghdr *nlmsg;
struct netlink_callback cb; struct netlink_callback cb;
struct nlattr **attrbuf;
memset(&cb, 0, sizeof(cb)); memset(&cb, 0, sizeof(cb));
cb.nlh = (struct nlmsghdr *)arg->data; cb.nlh = (struct nlmsghdr *)arg->data;
...@@ -201,19 +202,28 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, ...@@ -201,19 +202,28 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
return -ENOMEM; return -ENOMEM;
} }
attrbuf = kmalloc_array(tipc_genl_family.maxattr + 1,
sizeof(struct nlattr *), GFP_KERNEL);
if (!attrbuf) {
err = -ENOMEM;
goto err_out;
}
do { do {
int rem; int rem;
len = (*cmd->dumpit)(buf, &cb); len = (*cmd->dumpit)(buf, &cb);
nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) { nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) {
struct nlattr **attrs; err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN,
attrbuf,
err = tipc_nlmsg_parse(nlmsg, &attrs); tipc_genl_family.maxattr,
tipc_genl_family.policy,
NULL);
if (err) if (err)
goto err_out; goto err_out;
err = (*cmd->format)(msg, attrs); err = (*cmd->format)(msg, attrbuf);
if (err) if (err)
goto err_out; goto err_out;
...@@ -231,6 +241,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, ...@@ -231,6 +241,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
err = 0; err = 0;
err_out: err_out:
kfree(attrbuf);
tipc_dump_done(&cb); tipc_dump_done(&cb);
kfree_skb(buf); kfree_skb(buf);
......
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