diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2007-08-10 16:00:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-08-11 18:47:40 -0400 |
commit | a75de1b3799f8933d6d2b64bdf31194368ec98ab (patch) | |
tree | 9fc97f1b35300ca40463b74ac965e7580d61af70 /fs/ecryptfs | |
parent | b9a0620779d3714abd63dfc28284f5fa2c1fc091 (diff) |
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: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Acked-by: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/main.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index e557a6766927..a98497264fe8 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -813,6 +813,15 @@ out: | |||
813 | return rc; | 813 | return rc; |
814 | } | 814 | } |
815 | 815 | ||
816 | static void do_sysfs_unregistration(void) | ||
817 | { | ||
818 | sysfs_remove_file(&ecryptfs_subsys.kobj, | ||
819 | &sysfs_attr_version.attr); | ||
820 | sysfs_remove_file(&ecryptfs_subsys.kobj, | ||
821 | &sysfs_attr_version_str.attr); | ||
822 | subsystem_unregister(&ecryptfs_subsys); | ||
823 | } | ||
824 | |||
816 | static int __init ecryptfs_init(void) | 825 | static int __init ecryptfs_init(void) |
817 | { | 826 | { |
818 | int rc; | 827 | int rc; |
@@ -851,6 +860,9 @@ static int __init ecryptfs_init(void) | |||
851 | if (rc) { | 860 | if (rc) { |
852 | ecryptfs_printk(KERN_ERR, "Failure occured while attempting to " | 861 | ecryptfs_printk(KERN_ERR, "Failure occured while attempting to " |
853 | "initialize the eCryptfs netlink socket\n"); | 862 | "initialize the eCryptfs netlink socket\n"); |
863 | do_sysfs_unregistration(); | ||
864 | unregister_filesystem(&ecryptfs_fs_type); | ||
865 | ecryptfs_free_kmem_caches(); | ||
854 | } | 866 | } |
855 | out: | 867 | out: |
856 | return rc; | 868 | return rc; |
@@ -858,11 +870,7 @@ out: | |||
858 | 870 | ||
859 | static void __exit ecryptfs_exit(void) | 871 | static void __exit ecryptfs_exit(void) |
860 | { | 872 | { |
861 | sysfs_remove_file(&ecryptfs_subsys.kobj, | 873 | do_sysfs_unregistration(); |
862 | &sysfs_attr_version.attr); | ||
863 | sysfs_remove_file(&ecryptfs_subsys.kobj, | ||
864 | &sysfs_attr_version_str.attr); | ||
865 | subsystem_unregister(&ecryptfs_subsys); | ||
866 | ecryptfs_release_messaging(ecryptfs_transport); | 874 | ecryptfs_release_messaging(ecryptfs_transport); |
867 | unregister_filesystem(&ecryptfs_fs_type); | 875 | unregister_filesystem(&ecryptfs_fs_type); |
868 | ecryptfs_free_kmem_caches(); | 876 | ecryptfs_free_kmem_caches(); |