[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0805222155150.6294@sbz-30.cs.Helsinki.FI>
Date: Thu, 22 May 2008 21:55:37 +0300 (EEST)
From: Pekka J Enberg <penberg@...helsinki.fi>
To: kaber@...sh.net
cc: netfilter-devel@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, mpm@...enic.com, clameter@....com
Subject: [PATCH] netfilter: use krealloc() in nf_conntrack_extend.c V2
To: kaber@...sh.net
[PATCH] netfilter: use krealloc() in nf_conntrack_extend.c V2
From: Pekka Enberg <penberg@...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
net/netfilter/nf_conntrack_extend.c to use krealloc().
Cc: <netfilter-devel@...r.kernel.org>
Cc: <netdev@...r.kernel.org>
Cc: Matt Mackall <mpm@...enic.com>
Cc: Christoph Lameter <clameter@....com>
Signed-off-by: Pekka Enberg <penberg@...helsinki.fi>
---
Patrick, please use this patch instead. The previous one did the moving
unconditionally which is wrong. This one moves entries around only if
krealloc() allocated a new buffer.
net/netfilter/nf_conntrack_extend.c | 10 ++++------
1 file changed, 4 insertions(+), 6 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:52:12.000000000 +0300
+++ slab-2.6/net/netfilter/nf_conntrack_extend.c 2008-05-22 21:52:26.000000000 +0300
@@ -88,13 +88,11 @@
newlen = newoff + t->len;
rcu_read_unlock();
- if (newlen >= ksize(ct->ext)) {
- new = kmalloc(newlen, gfp);
- if (!new)
- return NULL;
-
- memcpy(new, ct->ext, ct->ext->len);
+ new = krealloc(ct->ext, newlen, gfp);
+ if (!new)
+ return NULL;
+ if (new != ct->ext) {
for (i = 0; i < NF_CT_EXT_NUM; i++) {
if (!nf_ct_ext_exist(ct, i))
continue;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists