aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/inet_hashtables.h
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-11-26 07:23:31 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2007-11-26 07:23:31 -0500
commit218ad12f42e0b6207105cde8fd13017d1ed449e4 (patch)
tree2f79b20a20ccfeeea1f44b82d9ec2ef0eb2758de /include/net/inet_hashtables.h
parent8053fc3de720e1027d690f892ff7d7c1737fdd9d (diff)
[IPV4]: Fix memory leak in inet_hashtables.h when NUMA is on
The inet_ehash_locks_alloc() looks like this: #ifdef CONFIG_NUMA if (size > PAGE_SIZE) x = vmalloc(...); else #endif x = kmalloc(...); Unlike it, the inet_ehash_locks_alloc() looks like this: #ifdef CONFIG_NUMA if (size > PAGE_SIZE) vfree(x); else #else kfree(x); #endif The error is obvious - if the NUMA is on and the size is less than the PAGE_SIZE we leak the pointer (kfree is inside the #else branch). Compiler doesn't warn us because after the kfree(x) there's a "x = NULL" assignment, so here's another (minor?) bug: we don't set x to NULL under certain circumstances. Boring explanation, I know... Patch explains it better. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/net/inet_hashtables.h')
-rw-r--r--include/net/inet_hashtables.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 469216d93663..37f6cb112127 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -186,9 +186,8 @@ static inline void inet_ehash_locks_free(struct inet_hashinfo *hashinfo)
186 if (size > PAGE_SIZE) 186 if (size > PAGE_SIZE)
187 vfree(hashinfo->ehash_locks); 187 vfree(hashinfo->ehash_locks);
188 else 188 else
189#else
190 kfree(hashinfo->ehash_locks);
191#endif 189#endif
190 kfree(hashinfo->ehash_locks);
192 hashinfo->ehash_locks = NULL; 191 hashinfo->ehash_locks = NULL;
193 } 192 }
194} 193}