[PATCH net-next] ipv6: fix a possible double free

Subsystems: networking [general], networking [ipv4/ipv6], the rest

STALE5502d REVIEWED: 1 (0M)

1 review trailer.

2 messages, 2 authors, 2011-09-20 · open the first message on its own page

[PATCH net-next] ipv6: fix a possible double free

From: <hidden>
Date: 2011-09-20 05:52:38

From: Roy.Li <redacted>

When calling snmp6_alloc_dev fails, the snmp6 relevant memory
are freed by snmp6_alloc_dev. Calling in6_dev_finish_destroy
will free these memory twice.

Double free will lead that undefined behavior occurs.

Signed-off-by: Roy.Li <redacted>
Acked-by: Eric Dumazet <redacted>
---
 net/ipv6/addrconf.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index f012ebd..12368c5 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -374,8 +374,8 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
 			"%s(): cannot allocate memory for statistics; dev=%s.\n",
 			__func__, dev->name));
 		neigh_parms_release(&nd_tbl, ndev->nd_parms);
-		ndev->dead = 1;
-		in6_dev_finish_destroy(ndev);
+		dev_put(dev);
+		kfree(ndev);
 		return NULL;
 	}
 
-- 
1.7.1

Re: [PATCH net-next] ipv6: fix a possible double free

From: David Miller <davem@davemloft.net>
Date: 2011-09-20 19:12:35

From: <redacted>
Date: Tue, 20 Sep 2011 13:52:16 +0800
From: Roy.Li <redacted>

When calling snmp6_alloc_dev fails, the snmp6 relevant memory
are freed by snmp6_alloc_dev. Calling in6_dev_finish_destroy
will free these memory twice.

Double free will lead that undefined behavior occurs.

Signed-off-by: Roy.Li <redacted>
Acked-by: Eric Dumazet <redacted>
Applied and queued up for -stable, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help