Commit d1fb5559 authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

netlink: fix state reallocation in policy export

Evidently, when I did this previously, we didn't have more than
10 policies and didn't run into the reallocation path, because
it's missing a memset() for the unused policies. Fix that.

Fixes: d07dcf9a ("netlink: add infrastructure to expose policies to userspace")
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b4c8998b
...@@ -51,6 +51,9 @@ static int add_policy(struct nl_policy_dump **statep, ...@@ -51,6 +51,9 @@ static int add_policy(struct nl_policy_dump **statep,
if (!state) if (!state)
return -ENOMEM; return -ENOMEM;
memset(&state->policies[state->n_alloc], 0,
flex_array_size(state, policies, n_alloc - state->n_alloc));
state->policies[state->n_alloc].policy = policy; state->policies[state->n_alloc].policy = policy;
state->policies[state->n_alloc].maxtype = maxtype; state->policies[state->n_alloc].maxtype = maxtype;
state->n_alloc = n_alloc; state->n_alloc = n_alloc;
......
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