summaryrefslogtreecommitdiffhomepage
path: root/net/netlink/genetlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/netlink/genetlink.c')
-rw-r--r--net/netlink/genetlink.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index a23d4c51c089..d251d894afd4 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -92,10 +92,8 @@ static unsigned long mc_group_start = 0x3 | BIT(GENL_ID_CTRL) |
static unsigned long *mc_groups = &mc_group_start;
static unsigned long mc_groups_longs = 1;
-/* We need the last attribute with non-zero ID therefore a 2-entry array */
static struct nla_policy genl_policy_reject_all[] = {
{ .type = NLA_REJECT },
- { .type = NLA_REJECT },
};
static int genl_ctrl_event(int event, const struct genl_family *family,
@@ -106,13 +104,10 @@ static void
genl_op_fill_in_reject_policy(const struct genl_family *family,
struct genl_ops *op)
{
- BUILD_BUG_ON(ARRAY_SIZE(genl_policy_reject_all) - 1 != 1);
-
if (op->policy || op->cmd < family->resv_start_op)
return;
op->policy = genl_policy_reject_all;
- op->maxattr = 1;
}
static void
@@ -123,7 +118,6 @@ genl_op_fill_in_reject_policy_split(const struct genl_family *family,
return;
op->policy = genl_policy_reject_all;
- op->maxattr = 1;
}
static const struct genl_family *genl_family_find_byid(unsigned int id)
@@ -250,6 +244,7 @@ genl_get_cmd_split(u32 cmd, u8 flag, const struct genl_family *family,
if (family->split_ops[i].cmd == cmd &&
family->split_ops[i].flags & flag) {
*op = family->split_ops[i];
+ genl_op_fill_in_reject_policy_split(family, op);
return 0;
}
@@ -934,12 +929,17 @@ genl_family_rcv_msg_attrs_parse(const struct genl_family *family,
struct nlattr **attrbuf;
int err;
- if (!ops->maxattr)
+ if (!ops->policy)
return NULL;
- attrbuf = kmalloc_objs(struct nlattr *, ops->maxattr + 1);
- if (!attrbuf)
- return ERR_PTR(-ENOMEM);
+ if (ops->maxattr) {
+ attrbuf = kmalloc_objs(struct nlattr *, ops->maxattr + 1);
+ if (!attrbuf)
+ return ERR_PTR(-ENOMEM);
+ } else {
+ /* Reject all policy, __nlmsg_parse() will just validate */
+ attrbuf = NULL;
+ }
err = __nlmsg_parse(nlh, hdrlen, attrbuf, ops->maxattr, ops->policy,
validate, extack);