Netdev List
 help / color / mirror / Atom feed
From: Horia Geanta <horia.geanta@freescale.com>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: <netdev@vger.kernel.org>
Subject: [PATCH] xfrm: fix potential incorrect pointer dereference in xfrm_bundle_create
Date: Sat, 25 Jan 2014 20:47:53 +0200	[thread overview]
Message-ID: <1390675673-20682-1-git-send-email-horia.geanta@freescale.com> (raw)

Return value of xfrm_alloc_dst might be an error code.
Need to check this before using the pointer safely.

Signed-off-by: Horia Geanta <horia.geanta@freescale.com>
---
 net/xfrm/xfrm_policy.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 9a91f74..f230f2a 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1541,7 +1541,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
 
 	for (; i < nx; i++) {
 		struct xfrm_dst *xdst = xfrm_alloc_dst(net, family);
-		struct dst_entry *dst1 = &xdst->u.dst;
+		struct dst_entry *dst1;
 
 		err = PTR_ERR(xdst);
 		if (IS_ERR(xdst)) {
@@ -1560,6 +1560,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
 		} else
 			inner_mode = xfrm[i]->inner_mode;
 
+		dst1 = &xdst->u.dst;
+
 		if (!dst_prev)
 			dst0 = dst1;
 		else {
-- 
1.8.3.1

             reply	other threads:[~2014-01-25 18:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-25 18:47 Horia Geanta [this message]
2014-01-25 19:07 ` [PATCH] xfrm: fix potential incorrect pointer dereference in xfrm_bundle_create David Miller
2014-01-25 19:32   ` Joe Perches
2014-01-26  2:05     ` 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=1390675673-20682-1-git-send-email-horia.geanta@freescale.com \
    --to=horia.geanta@freescale.com \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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