Netdev List
 help / color / mirror / Atom feed
* [PATCH] xfrm: fix potential incorrect pointer dereference in xfrm_bundle_create
@ 2014-01-25 18:47 Horia Geanta
  2014-01-25 19:07 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Horia Geanta @ 2014-01-25 18:47 UTC (permalink / raw)
  To: Steffen Klassert; +Cc: netdev

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-26  2:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-25 18:47 [PATCH] xfrm: fix potential incorrect pointer dereference in xfrm_bundle_create Horia Geanta
2014-01-25 19:07 ` David Miller
2014-01-25 19:32   ` Joe Perches
2014-01-26  2:05     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox