public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet•com>
To: David Miller <davem@davemloft•net>,
	Eric Dumazet <eric.dumazet@gmail•com>
Cc: netdev@vger•kernel.org
Subject: [PATCH net-next 2/2] xfrm: Initialize the struct xfrm_dst behind the dst_enty field
Date: Fri, 6 Jul 2012 11:39:34 +0200	[thread overview]
Message-ID: <20120706093934.GI1869@secunet.com> (raw)
In-Reply-To: <20120706093709.GH1869@secunet.com>

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>
---
 net/xfrm/xfrm_policy.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 6e97855..79c498b 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -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 = (struct dst_entry *)xdst;
+
+		memset(dst + 1, 0, sizeof(*xdst) - sizeof(*dst));
 		xdst->flo.ops = &xfrm_bundle_fc_ops;
 	} else
 		xdst = ERR_PTR(-ENOBUFS);
-- 
1.7.0.4

  reply	other threads:[~2012-07-06  9:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06  9:37 [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field Steffen Klassert
2012-07-06  9:39 ` Steffen Klassert [this message]
2012-07-06 10:57 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120706093934.GI1869@secunet.com \
    --to=steffen.klassert@secunet$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox