[netfilter-cvslog] r3387 - trunk/nfsim/core
rusty at netfilter.org
rusty at netfilter.org
Wed Dec 15 05:47:01 CET 2004
Author: rusty at netfilter.org
Date: 2004-12-15 05:47:01 +0100 (Wed, 15 Dec 2004)
New Revision: 3387
Modified:
trunk/nfsim/core/seq_file.c
Log:
Don't use kmalloc: it will fail with --failtest, and we don't care.
But use talloc off a context, which we canc heck for leaks in future.
Modified: trunk/nfsim/core/seq_file.c
===================================================================
--- trunk/nfsim/core/seq_file.c 2004-12-15 04:45:55 UTC (rev 3386)
+++ trunk/nfsim/core/seq_file.c 2004-12-15 04:47:01 UTC (rev 3387)
@@ -13,6 +13,16 @@
#include <asm/uaccess.h>
#include <asm/page.h>
+#include "talloc.h"
+static void *__seq_file_ctx;
+
+static void init(void)
+{
+ __seq_file_ctx = talloc_size(NULL, 1);
+}
+init_call(init);
+/* FIXME: Check __seq_file_ctx is empty on cleanup. --RR */
+
/**
* seq_open - initialize sequential file
* @file: file we initialize
@@ -28,7 +38,7 @@
*/
int seq_open(struct file *file, struct seq_operations *op)
{
- struct seq_file *p = kmalloc(sizeof(*p), GFP_KERNEL);
+ struct seq_file *p = talloc(__seq_file_ctx, struct seq_file);
if (!p)
return -ENOMEM;
memset(p, 0, sizeof(*p));
@@ -60,7 +70,7 @@
down(&m->sem);
/* grab buffer if we didn't have one */
if (!m->buf) {
- m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
+ m->buf = talloc_size(__seq_file_ctx, m->size = PAGE_SIZE);
if (!m->buf)
goto Enomem;
}
@@ -92,7 +102,7 @@
goto Fill;
m->op->stop(m, p);
kfree(m->buf);
- m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
+ m->buf = talloc_size(__seq_file_ctx, m->size <<= 1);
if (!m->buf)
goto Enomem;
m->count = 0;
@@ -156,7 +166,7 @@
if (!offset)
return 0;
if (!m->buf) {
- m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
+ m->buf = talloc_size(__seq_file_ctx, m->size = PAGE_SIZE);
if (!m->buf)
return -ENOMEM;
}
@@ -189,7 +199,7 @@
Eoverflow:
m->op->stop(m, p);
kfree(m->buf);
- m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
+ m->buf = talloc_size(__seq_file_ctx, m->size <<= 1);
return !m->buf ? -ENOMEM : -EAGAIN;
}
@@ -320,7 +330,8 @@
int single_open(struct file *file, int (*show)(struct seq_file *, void *),
void *data)
{
- struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
+ struct seq_operations *op = talloc(__seq_file_ctx,
+ struct seq_operations);
int res = -ENOMEM;
if (op) {
More information about the netfilter-cvslog
mailing list