summaryrefslogtreecommitdiffstats
path: root/fs/ncpfs/inode.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2006-12-13 00:35:13 -0800
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-13 09:05:53 -0800
commit1de241268d7b6bea05d64f9269bf9aa90be49ff1 (patch)
treec50ef7b5a4480cac82f92c4131d0c7357a86c15b /fs/ncpfs/inode.c
parent2154227a2c6cf04e28576b59c684123eb0e81958 (diff)
downloadlinux-stable-1de241268d7b6bea05d64f9269bf9aa90be49ff1.tar.gz
linux-stable-1de241268d7b6bea05d64f9269bf9aa90be49ff1.tar.bz2
linux-stable-1de241268d7b6bea05d64f9269bf9aa90be49ff1.zip
[PATCH] ncpfs: ensure we free wdog_pid on parse_option or fill_inode failure
This took a little refactoring but now errors are handled cleanly. When this code used pid_t values this wasn't necessary because you can't leak a pid_t. Thanks to Peter Vandrovec for spotting this. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Peter Vandrovec <vandrove@vc.cvut.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ncpfs/inode.c')
-rw-r--r--fs/ncpfs/inode.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 861d950ac99a..67a90bf795d5 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -327,6 +327,7 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
char *optarg;
unsigned long optint;
int version = 0;
+ int ret;
data->flags = 0;
data->int_flags = 0;
@@ -343,8 +344,9 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
data->mounted_vol[0] = 0;
while ((optval = ncp_getopt("ncpfs", &options, ncp_opts, NULL, &optarg, &optint)) != 0) {
- if (optval < 0)
- return optval;
+ ret = optval;
+ if (ret < 0)
+ goto err;
switch (optval) {
case 'u':
data->uid = optint;
@@ -380,18 +382,21 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
data->info_fd = optint;
break;
case 'v':
- if (optint < NCP_MOUNT_VERSION_V4) {
- return -ECHRNG;
- }
- if (optint > NCP_MOUNT_VERSION_V5) {
- return -ECHRNG;
- }
+ ret = -ECHRNG;
+ if (optint < NCP_MOUNT_VERSION_V4)
+ goto err;
+ if (optint > NCP_MOUNT_VERSION_V5)
+ goto err;
version = optint;
break;
}
}
return 0;
+err:
+ put_pid(data->wdog_pid);
+ data->wdog_pid = NULL;
+ return ret;
}
static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
@@ -409,6 +414,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
#endif
struct ncp_entry_info finfo;
+ data.wdog_pid = NULL;
server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
if (!server)
return -ENOMEM;
@@ -679,6 +685,7 @@ out_fput:
*/
fput(ncp_filp);
out:
+ put_pid(data.wdog_pid);
sb->s_fs_info = NULL;
kfree(server);
return error;