Commit 988d8f66 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] kNFSd: Make sure export_open cleans up on failure.

Currently if the kmalloc in exports_open fails,
the seq_file isn't seq_released.

We now do the kmalloc first, and make sure to kfree
if seq_open fails.
parent b9d189e5
......@@ -127,14 +127,16 @@ extern struct seq_operations nfs_exports_op;
static int exports_open(struct inode *inode, struct file *file)
{
int res;
char *namebuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (namebuf == NULL)
return -ENOMEM;
res = seq_open(file, &nfs_exports_op);
if (!res) {
char *namebuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (namebuf == NULL)
res = -ENOMEM;
else
((struct seq_file *)file->private_data)->private = namebuf;
}
if (res)
kfree(namebuf);
else
((struct seq_file *)file->private_data)->private = namebuf;
return res;
}
static int exports_release(struct inode *inode, struct file *file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment