From 988d8f66e1efc1d0c71cf131ac575478f5f49ccb Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 30 Oct 2002 00:24:22 -0800 Subject: [PATCH] [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. --- fs/nfsd/nfsctl.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 85ca18fe1b50..4d208cbaa5d9 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -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) -- 2.39.5