Commit a75de1b3 authored by Ryusuke Konishi's avatar Ryusuke Konishi Committed by Linus Torvalds

eCryptfs: fix error handling in ecryptfs_init

ecryptfs_init() exits without doing any cleanup jobs if
ecryptfs_init_messaging() fails.  In that case, eCryptfs leaves
sysfs entries, leaks memory, and causes an invalid page fault.
This patch fixes the problem.
Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Acked-by: default avatarMichael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b9a06207
...@@ -813,6 +813,15 @@ out: ...@@ -813,6 +813,15 @@ out:
return rc; return rc;
} }
static void do_sysfs_unregistration(void)
{
sysfs_remove_file(&ecryptfs_subsys.kobj,
&sysfs_attr_version.attr);
sysfs_remove_file(&ecryptfs_subsys.kobj,
&sysfs_attr_version_str.attr);
subsystem_unregister(&ecryptfs_subsys);
}
static int __init ecryptfs_init(void) static int __init ecryptfs_init(void)
{ {
int rc; int rc;
...@@ -851,6 +860,9 @@ static int __init ecryptfs_init(void) ...@@ -851,6 +860,9 @@ static int __init ecryptfs_init(void)
if (rc) { if (rc) {
ecryptfs_printk(KERN_ERR, "Failure occured while attempting to " ecryptfs_printk(KERN_ERR, "Failure occured while attempting to "
"initialize the eCryptfs netlink socket\n"); "initialize the eCryptfs netlink socket\n");
do_sysfs_unregistration();
unregister_filesystem(&ecryptfs_fs_type);
ecryptfs_free_kmem_caches();
} }
out: out:
return rc; return rc;
...@@ -858,11 +870,7 @@ out: ...@@ -858,11 +870,7 @@ out:
static void __exit ecryptfs_exit(void) static void __exit ecryptfs_exit(void)
{ {
sysfs_remove_file(&ecryptfs_subsys.kobj, do_sysfs_unregistration();
&sysfs_attr_version.attr);
sysfs_remove_file(&ecryptfs_subsys.kobj,
&sysfs_attr_version_str.attr);
subsystem_unregister(&ecryptfs_subsys);
ecryptfs_release_messaging(ecryptfs_transport); ecryptfs_release_messaging(ecryptfs_transport);
unregister_filesystem(&ecryptfs_fs_type); unregister_filesystem(&ecryptfs_fs_type);
ecryptfs_free_kmem_caches(); ecryptfs_free_kmem_caches();
......
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