|
@@ -51,15 +51,16 @@ static void *seq_buf_alloc(unsigned long size)
|
|
|
*/
|
|
|
int seq_open(struct file *file, const struct seq_operations *op)
|
|
|
{
|
|
|
- struct seq_file *p = file->private_data;
|
|
|
+ struct seq_file *p;
|
|
|
+
|
|
|
+ WARN_ON(file->private_data);
|
|
|
+
|
|
|
+ p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
|
+ if (!p)
|
|
|
+ return -ENOMEM;
|
|
|
+
|
|
|
+ file->private_data = p;
|
|
|
|
|
|
- if (!p) {
|
|
|
- p = kmalloc(sizeof(*p), GFP_KERNEL);
|
|
|
- if (!p)
|
|
|
- return -ENOMEM;
|
|
|
- file->private_data = p;
|
|
|
- }
|
|
|
- memset(p, 0, sizeof(*p));
|
|
|
mutex_init(&p->lock);
|
|
|
p->op = op;
|
|
|
#ifdef CONFIG_USER_NS
|