: ipset kernel memory allocations
PATCH 1/1 : ipset kernel memory allocations
Hi,
The kernel ipset code in patch-o-matic-ng has code like this in three places:
tmp = kmalloc(...);
if (!map) { ... }
i.e. checking the wrong variable. Map cannot be false here, it is used in the size calculation for kmalloc. Probably all of these originate from a single source. The patch below fixes them.
/Jones
set/linux/net/ipv4/netfilter/ip_set_iphash.c +1 -1
@@ -171,7 +171,7 @@ tmp =kmalloc (sizeof (struct ip_set_iphash ) + map->probes *sizeof (uint32_t ),GFP_ATOMIC ); -if (!map) { +if (!tmp) {DP ("out of memory for %d bytes" ,sizeof (struct ip_set_iphash ) + map->probes *sizeof (uint32_t ));
set/linux/net/ipv4/netfilter/ip_set_ipporthash.c +1 -1
@@ -270,7 +270,7 @@ tmp =kmalloc (sizeof (struct ip_set_ipporthash ) + map->probes *sizeof (uint32_t ),GFP_ATOMIC ); -if (!map) { +if (!tmp) {DP ("out of memory for %d bytes" ,sizeof (struct ip_set_ipporthash ) + map->probes *sizeof (uint32_t ));
set/linux/net/ipv4/netfilter/ip_set_nethash.c +1 -1
@@ -234,7 +234,7 @@ tmp =kmalloc (sizeof (struct ip_set_nethash ) + map->probes *sizeof (uint32_t ),GFP_ATOMIC ); -if (!map) { +if (!tmp) {DP ("out of memory for %d bytes" ,sizeof (struct ip_set_nethash ) + map->probes *sizeof (uint32_t ));
set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c +1 -1
@@ -170,7 +170,7 @@ tmp =kmalloc (sizeof (struct ip_set_iphash ) + map->probes *sizeof (uint32_t ),GFP_ATOMIC ); -if (!map) { +if (!tmp) {DP ("out of memory for %d bytes" ,sizeof (struct ip_set_iphash ) + map->probes *sizeof (uint32_t ));
set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c +1 -1
@@ -269,7 +269,7 @@ tmp =kmalloc (sizeof (struct ip_set_ipporthash ) + map->probes *sizeof (uint32_t ),GFP_ATOMIC ); -if (!map) { +if (!tmp) {DP ("out of memory for %d bytes" ,sizeof (struct ip_set_ipporthash ) + map->probes *sizeof (uint32_t ));
set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c +1 -1
@@ -233,7 +233,7 @@ tmp =kmalloc (sizeof (struct ip_set_nethash ) + map->probes *sizeof (uint32_t ),GFP_ATOMIC ); -if (!map) { +if (!tmp) {DP ("out of memory for %d bytes" ,sizeof (struct ip_set_nethash ) + map->probes *sizeof (uint32_t ));
Quoted 10 lines · Jones Desougi
The kernel ipset code in patch-o-matic-ng has code like this in three places:
tmp = kmalloc(...);
if (!map) { ... }i.e. checking the wrong variable. Map cannot be false here, it is used in the size calculation for kmalloc. Probably all of these originate from a single source. The patch below fixes them.
Nice example of a copy-paste bug handed down from one module to the next one :-(. Thank you the good catch and the patch!
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary