Commit 1de24126 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Linus Torvalds

[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: default avatarEric W. Biederman <ebiederm@xmission.com>
Cc: Peter Vandrovec <vandrove@vc.cvut.cz>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2154227a
...@@ -327,6 +327,7 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options) ...@@ -327,6 +327,7 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
char *optarg; char *optarg;
unsigned long optint; unsigned long optint;
int version = 0; int version = 0;
int ret;
data->flags = 0; data->flags = 0;
data->int_flags = 0; data->int_flags = 0;
...@@ -343,8 +344,9 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options) ...@@ -343,8 +344,9 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
data->mounted_vol[0] = 0; data->mounted_vol[0] = 0;
while ((optval = ncp_getopt("ncpfs", &options, ncp_opts, NULL, &optarg, &optint)) != 0) { while ((optval = ncp_getopt("ncpfs", &options, ncp_opts, NULL, &optarg, &optint)) != 0) {
if (optval < 0) ret = optval;
return optval; if (ret < 0)
goto err;
switch (optval) { switch (optval) {
case 'u': case 'u':
data->uid = optint; data->uid = optint;
...@@ -380,18 +382,21 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options) ...@@ -380,18 +382,21 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
data->info_fd = optint; data->info_fd = optint;
break; break;
case 'v': case 'v':
if (optint < NCP_MOUNT_VERSION_V4) { ret = -ECHRNG;
return -ECHRNG; if (optint < NCP_MOUNT_VERSION_V4)
} goto err;
if (optint > NCP_MOUNT_VERSION_V5) { if (optint > NCP_MOUNT_VERSION_V5)
return -ECHRNG; goto err;
}
version = optint; version = optint;
break; break;
} }
} }
return 0; 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) 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) ...@@ -409,6 +414,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
#endif #endif
struct ncp_entry_info finfo; struct ncp_entry_info finfo;
data.wdog_pid = NULL;
server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL); server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
if (!server) if (!server)
return -ENOMEM; return -ENOMEM;
...@@ -679,6 +685,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -679,6 +685,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
*/ */
fput(ncp_filp); fput(ncp_filp);
out: out:
put_pid(data.wdog_pid);
sb->s_fs_info = NULL; sb->s_fs_info = NULL;
kfree(server); kfree(server);
return error; return error;
......
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