@@ -1937,9 +1937,9 @@ void nla_get_range_signed(const struct nla_policy *pt,
struct netlink_policy_dump_state;
-int netlink_policy_dump_start(const struct nla_policy *policy,
- unsigned int maxtype,
- struct netlink_policy_dump_state **state);
+struct netlink_policy_dump_state *
+netlink_policy_dump_start(const struct nla_policy *policy,
+ unsigned int maxtype);
bool netlink_policy_dump_loop(struct netlink_policy_dump_state *state);
int netlink_policy_dump_write(struct sk_buff *skb,
struct netlink_policy_dump_state *state);
@@ -1164,7 +1164,10 @@ static int ctrl_dumppolicy_start(struct netlink_callback *cb)
if (!op.policy)
return -ENODATA;
- return netlink_policy_dump_start(op.policy, op.maxattr, &ctx->state);
+ ctx->state = netlink_policy_dump_start(op.policy, op.maxattr);
+ if (IS_ERR(ctx->state))
+ return PTR_ERR(ctx->state);
+ return 0;
}
static int ctrl_dumppolicy(struct sk_buff *skb, struct netlink_callback *cb)
@@ -76,17 +76,14 @@ static unsigned int get_policy_idx(struct netlink_policy_dump_state *state,
return -1;
}
-int netlink_policy_dump_start(const struct nla_policy *policy,
- unsigned int maxtype,
- struct netlink_policy_dump_state **statep)
+struct netlink_policy_dump_state *
+netlink_policy_dump_start(const struct nla_policy *policy,
+ unsigned int maxtype)
{
struct netlink_policy_dump_state *state;
unsigned int policy_idx;
int err;
- if (*statep)
- return 0;
-
/*
* walk the policies and nested ones first, and build
* a linear list of them.
@@ -95,12 +92,12 @@ int netlink_policy_dump_start(const struct nla_policy *policy,
state = kzalloc(struct_size(state, policies, INITIAL_POLICIES_ALLOC),
GFP_KERNEL);
if (!state)
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
state->n_alloc = INITIAL_POLICIES_ALLOC;
err = add_policy(&state, policy, maxtype);
if (err)
- return err;
+ return ERR_PTR(err);
for (policy_idx = 0;
policy_idx < state->n_alloc && state->policies[policy_idx].policy;
@@ -120,7 +117,7 @@ int netlink_policy_dump_start(const struct nla_policy *policy,
policy[type].nested_policy,
policy[type].len);
if (err)
- return err;
+ return ERR_PTR(err);
break;
default:
break;
@@ -128,9 +125,7 @@ int netlink_policy_dump_start(const struct nla_policy *policy,
}
}
- *statep = state;
-
- return 0;
+ return state;
}
static bool