Skip to content

Commit

Permalink
netlink: fix state reallocation in policy export
Browse files Browse the repository at this point in the history
[ Upstream commit d1fb555 ]

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: d07dcf9 ("netlink: add infrastructure to expose policies to userspace")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Johannes Berg authored and Greg Kroah-Hartman committed Aug 27, 2020
1 parent 1c0be9a commit 3f4be7a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/netlink/policy.c
Original file line number Diff line number Diff line change
@@ -51,6 +51,9 @@ static int add_policy(struct nl_policy_dump **statep,
if (!state)
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].maxtype = maxtype;
state->n_alloc = n_alloc;

0 comments on commit 3f4be7a

Please sign in to comment.