netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: use krealloc() in nf_conntrack_extend.c
@ 2008-05-22 18:47 Pekka J Enberg
  2008-05-22 18:55 ` [PATCH] netfilter: use krealloc() in nf_conntrack_extend.c V2 Pekka J Enberg
  0 siblings, 1 reply; 8+ messages in thread
From: Pekka J Enberg @ 2008-05-22 18:47 UTC (permalink / raw)
  To: kaber; +Cc: netfilter-devel, netdev, linux-kernel, mpm, clameter

From: Pekka Enberg <penberg@cs.helsinki.fi>

The ksize() API is going away because it is being abused and it doesn't even
work consistenly across different allocators. Therefore, convert the use 
of ksize() in net/netfilter/nf_conntrack_extend.c to krealloc() that is 
open-coded there.

Cc: Matt Mackall <mpm@selenic.com>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 net/netfilter/nf_conntrack_extend.c |   31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

Index: slab-2.6/net/netfilter/nf_conntrack_extend.c
===================================================================
--- slab-2.6.orig/net/netfilter/nf_conntrack_extend.c	2008-05-22 21:38:14.000000000 +0300
+++ slab-2.6/net/netfilter/nf_conntrack_extend.c	2008-05-22 21:38:21.000000000 +0300
@@ -88,27 +88,22 @@
 	newlen = newoff + t->len;
 	rcu_read_unlock();
 
-	if (newlen >= ksize(ct->ext)) {
-		new = kmalloc(newlen, gfp);
-		if (!new)
-			return NULL;
+	new = krealloc(ct->ext, newlen, gfp);
+	if (!new)
+		return NULL;
 
-		memcpy(new, ct->ext, ct->ext->len);
-
-		for (i = 0; i < NF_CT_EXT_NUM; i++) {
-			if (!nf_ct_ext_exist(ct, i))
-				continue;
+	for (i = 0; i < NF_CT_EXT_NUM; i++) {
+		if (!nf_ct_ext_exist(ct, i))
+			continue;
 
-			rcu_read_lock();
-			t = rcu_dereference(nf_ct_ext_types[i]);
-			if (t && t->move)
-				t->move((void *)new + new->offset[i],
-					(void *)ct->ext + ct->ext->offset[i]);
-			rcu_read_unlock();
-		}
-		kfree(ct->ext);
-		ct->ext = new;
+		rcu_read_lock();
+		t = rcu_dereference(nf_ct_ext_types[i]);
+		if (t && t->move)
+			t->move((void *)new + new->offset[i],
+				(void *)ct->ext + ct->ext->offset[i]);
+		rcu_read_unlock();
 	}
+	ct->ext = new;
 
 	ct->ext->offset[id] = newoff;
 	ct->ext->len = newlen;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-06-17 13:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22 18:47 [PATCH] netfilter: use krealloc() in nf_conntrack_extend.c Pekka J Enberg
2008-05-22 18:55 ` [PATCH] netfilter: use krealloc() in nf_conntrack_extend.c V2 Pekka J Enberg
2008-05-22 19:06   ` Patrick McHardy
2008-05-22 19:07     ` Pekka Enberg
2008-05-22 19:09       ` Patrick McHardy
2008-05-22 19:11         ` Pekka Enberg
2008-06-17 13:57           ` Patrick McHardy
2008-05-22 19:22   ` Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).