CIFS: Fix memory leak in cifs_do_mount
and simplify error handling code. Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
Родитель
6848b7334b
Коммит
641a58d66d
|
@ -556,9 +556,8 @@ cifs_do_mount(struct file_system_type *fs_type,
|
||||||
|
|
||||||
sb = sget(fs_type, NULL, set_anon_super, NULL);
|
sb = sget(fs_type, NULL, set_anon_super, NULL);
|
||||||
if (IS_ERR(sb)) {
|
if (IS_ERR(sb)) {
|
||||||
kfree(cifs_sb);
|
|
||||||
root = ERR_CAST(sb);
|
root = ERR_CAST(sb);
|
||||||
goto out;
|
goto out_cifs_sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -569,7 +568,7 @@ cifs_do_mount(struct file_system_type *fs_type,
|
||||||
cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
|
cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
|
||||||
if (cifs_sb->mountdata == NULL) {
|
if (cifs_sb->mountdata == NULL) {
|
||||||
root = ERR_PTR(-ENOMEM);
|
root = ERR_PTR(-ENOMEM);
|
||||||
goto err_out;
|
goto out_super;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb->s_flags = flags;
|
sb->s_flags = flags;
|
||||||
|
@ -581,21 +580,23 @@ cifs_do_mount(struct file_system_type *fs_type,
|
||||||
flags & MS_SILENT ? 1 : 0);
|
flags & MS_SILENT ? 1 : 0);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
root = ERR_PTR(rc);
|
root = ERR_PTR(rc);
|
||||||
goto err_out;
|
goto out_super;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb->s_flags |= MS_ACTIVE;
|
sb->s_flags |= MS_ACTIVE;
|
||||||
|
|
||||||
root = dget(sb->s_root);
|
root = dget(sb->s_root);
|
||||||
out:
|
goto out;
|
||||||
cifs_cleanup_volume_info(&volume_info);
|
|
||||||
return root;
|
|
||||||
|
|
||||||
err_out:
|
out_super:
|
||||||
kfree(cifs_sb->mountdata);
|
kfree(cifs_sb->mountdata);
|
||||||
|
deactivate_locked_super(sb);
|
||||||
|
|
||||||
|
out_cifs_sb:
|
||||||
unload_nls(cifs_sb->local_nls);
|
unload_nls(cifs_sb->local_nls);
|
||||||
kfree(cifs_sb);
|
kfree(cifs_sb);
|
||||||
deactivate_locked_super(sb);
|
|
||||||
|
out:
|
||||||
cifs_cleanup_volume_info(&volume_info);
|
cifs_cleanup_volume_info(&volume_info);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче