xfrm: Initialize the struct xfrm_dst behind the dst_enty field
authorSteffen Klassert <steffen.klassert@secunet.com>
Thu, 5 Jul 2012 23:39:34 +0000 (23:39 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 14 Jul 2012 07:29:12 +0000 (00:29 -0700)
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 <eric.dumazet@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/xfrm/xfrm_policy.c

index 6e97855b5842ded6555b98238a1ec10383a3acca..65bd1ca515178e76d2062075d34eaa3b45a23738 100644 (file)
@@ -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);