[patch-o-matic-ng] Nasty typo in ip_set_macipmac.c fixed. How it went unnoticed so long? Internal change: memory allocation must be initialized explicitely.

netfilter-cvslog-bounces at lists.netfilter.org netfilter-cvslog-bounces at lists.netfilter.org
Thu Jun 12 11:02:01 CEST 2008


Gitweb:		http://git.netfilter.org/cgi-bin/gitweb.cgi?p=patch-o-matic-ng.git;a=commit;h=f128471017faffffaddeda1fd3fec06ffcafda72
commit f128471017faffffaddeda1fd3fec06ffcafda72
Author:     Jozsef Kadlecsik <kadlec at blackhole.kfki.hu>
AuthorDate: Thu Jun 12 10:49:00 2008 +0200
Commit:     Jozsef Kadlecsik <kadlec at blackhole.kfki.hu>
CommitDate: Thu Jun 12 10:49:00 2008 +0200

    Nasty typo in ip_set_macipmac.c fixed. How it went unnoticed so long?
    Internal change: memory allocation must be initialized explicitely.
       via  f128471017faffffaddeda1fd3fec06ffcafda72 (commit)
      from  e238d904413de1f3acdf6f28556d6201ca3c384d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f128471017faffffaddeda1fd3fec06ffcafda72
Author: Jozsef Kadlecsik <kadlec at blackhole.kfki.hu>
Date:   Thu Jun 12 10:49:00 2008 +0200

    Nasty typo in ip_set_macipmac.c fixed. How it went unnoticed so long?
    Internal change: memory allocation must be initialized explicitely.

-----------------------------------------------------------------------

 .../include/linux/netfilter_ipv4/ip_set_malloc.h   |   12 ++++++------
 .../linux-2.6/net/ipv4/netfilter/ip_set_iphash.c   |    1 +
 .../net/ipv4/netfilter/ip_set_ipporthash.c         |    1 +
 .../linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c |    5 +++--
 .../linux-2.6/net/ipv4/netfilter/ip_set_nethash.c  |    1 +
 5 files changed, 12 insertions(+), 8 deletions(-)
Internal change: memory allocation must be initialized explicitely.

diff --git a/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h b/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h
index ac5d86a..30701f4 100644
--- a/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h
+++ b/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h
@@ -14,7 +14,7 @@ static inline bool init_max_page_size(void)
 #include <linux/kmalloc_sizes.h>
 #undef CACHE
 	if (page_size) {
-		if (!max_malloc_size)
+		if (max_malloc_size == 0)
 			max_malloc_size = page_size;
 
 		max_page_size = page_size;
@@ -35,6 +35,8 @@ __harray_malloc(size_t hashsize, size_t typesize, int flags)
 	struct harray *harray;
 	size_t max_elements, size, i, j;
 
+	BUG_ON(max_page_size == 0);
+
 	if (typesize > max_page_size)
 		return NULL;
 
@@ -80,9 +82,6 @@ harray_malloc(size_t hashsize, size_t typesize, int flags)
 {
 	void *harray;
 	
-	if (!max_page_size)
-		init_max_page_size();
-
 	do {
 		harray = __harray_malloc(hashsize, typesize, flags|__GFP_NOWARN);
 	} while (harray == NULL && init_max_page_size());
@@ -121,8 +120,7 @@ static inline void harray_flush(void *h, size_t hashsize, size_t typesize)
 /* General memory allocation and deallocation */
 static inline void * ip_set_malloc(size_t bytes)
 {
-	if (!max_malloc_size)
-		init_max_page_size();
+	BUG_ON(max_malloc_size == 0);
 
 	if (bytes > max_malloc_size)
 		return vmalloc(bytes);
@@ -132,6 +130,8 @@ static inline void * ip_set_malloc(size_t bytes)
 
 static inline void ip_set_free(void * data, size_t bytes)
 {
+	BUG_ON(max_malloc_size == 0);
+
 	if (bytes > max_malloc_size)
 		vfree(data);
 	else
diff --git a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c
index 63f7ac9..9b6f8d4 100644
--- a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c
+++ b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c
@@ -416,6 +416,7 @@ MODULE_PARM_DESC(limit, "maximal number of elements stored in the sets");
 
 static int __init ip_set_iphash_init(void)
 {
+	init_max_page_size();
 	return ip_set_register_set_type(&ip_set_iphash);
 }
 
diff --git a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c
index 0d562b8..b0a9e29 100644
--- a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c
+++ b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c
@@ -568,6 +568,7 @@ MODULE_PARM_DESC(limit, "maximal number of elements stored in the sets");
 
 static int __init ip_set_ipporthash_init(void)
 {
+	init_max_page_size();
 	return ip_set_register_set_type(&ip_set_ipporthash);
 }
 
diff --git a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c
index c07e331..57e1096 100644
--- a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c
+++ b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c
@@ -225,14 +225,14 @@ delip_kernel(struct ip_set *set,
 		       hash_ip);
 }
 
-static inline size_t members_size(ip_set_id_t from, ip_set_id_t to)
+static inline size_t members_size(ip_set_ip_t from, ip_set_ip_t to)
 {
 	return (size_t)((to - from + 1) * sizeof(struct ip_set_macip));
 }
 
 static int create(struct ip_set *set, const void *data, size_t size)
 {
-	int newbytes;
+	size_t newbytes;
 	struct ip_set_req_macipmap_create *req =
 	    (struct ip_set_req_macipmap_create *) data;
 	struct ip_set_macipmap *map;
@@ -361,6 +361,7 @@ MODULE_DESCRIPTION("macipmap type of IP sets");
 
 static int __init ip_set_macipmap_init(void)
 {
+	init_max_page_size();
 	return ip_set_register_set_type(&ip_set_macipmap);
 }
 
diff --git a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c
index d94cc32..b30c4c2 100644
--- a/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c
+++ b/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c
@@ -484,6 +484,7 @@ MODULE_PARM_DESC(limit, "maximal number of elements stored in the sets");
 
 static int __init ip_set_nethash_init(void)
 {
+	init_max_page_size();
 	return ip_set_register_set_type(&ip_set_nethash);
 }
 



More information about the netfilter-cvslog mailing list