mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-26 18:43:33 -05:00
[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>
This commit is contained in:
parent
2154227a2c
commit
1de241268d
1 changed files with 15 additions and 8 deletions
|
@ -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)
|
||||||
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)
|
||||||
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)
|
||||||
#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 @@ out_fput:
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue