Skip to contentSkip to conversation

ipv6: don't free static mem in the case of init_net

PATCH In review Hong Zhiguo 2 participants 2 messages Mar 25, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: don't free static mem in the case of init_net

---
 net/ipv6/addrconf.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +6 -2
index fa36a67..1f5f51f 100644
@@ -4891,10 +4891,14 @@ static int __net_init addrconf_init_net(struct net *net)
 err_reg_dflt:
 	__addrconf_sysctl_unregister(all);
 err_reg_all:
-	kfree(dflt);
+	if (dflt != &ipv6_devconf_dflt) {
+		kfree(dflt);
+	}
 #endif
 err_alloc_dflt:
-	kfree(all);
+	if (all != &ipv6_devconf) {
+		kfree(all);
+	}
 err_alloc_all:
 	return err;
 }
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

From: Hong Zhiguo <[email protected]>
Date: Tue, 26 Mar 2013 00:25:25 +0800

Quoted 1 line

1) This should be submitted against 'net' since it's clearly a real bug.

2) This needs to be fixed differently. We should always kmemdup() and create fresh copies of these objects, even for init_net. So 'dflt' and 'all' will start as "NULL" and always we will try to kmemdup(&ipv6_defconf, ...) and kmemdup(&ipv6_devconf_dflt, ...);