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,
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
return;
op->policy = genl_policy_reject_all;
- op->maxattr = 1;
}
static const struct genl_family *genl_family_find_byid(unsigned int id)
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);
struct netlink_policy_dump_state *state = *statep;
unsigned int old_n_alloc, n_alloc, i;
- if (!policy || !maxtype)
+ if (!policy)
return 0;
for (i = 0; i < state->n_alloc; i++) {
{
unsigned int i;
- if (WARN_ON(!policy || !maxtype))
+ if (WARN_ON(!policy))
return 0;
for (i = 0; i < state->n_alloc; i++) {