Skip to content

Commit

Permalink
xfrm: Initialize the struct xfrm_dst behind the dst_enty field
Browse files Browse the repository at this point in the history
We start initializing the struct xfrm_dst at the first field
behind the struct dst_enty. This is error prone because it
might leave a new field uninitialized. So start initializing
the struct xfrm_dst right behind the dst_entry.

Suggested-by: Eric Dumazet <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
klassert authored and davem330 committed Jul 14, 2012
1 parent 8104891 commit 141e369
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/xfrm/xfrm_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,8 +1353,9 @@ static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family)
xdst = dst_alloc(dst_ops, NULL, 0, 0, 0);

if (likely(xdst)) {
memset(&xdst->u.rt6.rt6i_table, 0,
sizeof(*xdst) - sizeof(struct dst_entry));
struct dst_entry *dst = &xdst->u.dst;

memset(dst + 1, 0, sizeof(*xdst) - sizeof(*dst));
xdst->flo.ops = &xfrm_bundle_fc_ops;
} else
xdst = ERR_PTR(-ENOBUFS);
Expand Down

0 comments on commit 141e369

Please sign in to comment.