aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMichael Halcrow <mhalcrow@us.ibm.com>2007-10-16 04:28:07 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:12 -0400
commitcf81f89d9a85b1825d8c8cf1f8f0e2c98cc72823 (patch)
treeff22f49549bf5caeb3069fffd1e01ab76c8ec218 /fs
parent5dda6992a3138f3839dcaecbcd2fbea4dd514c7c (diff)
ecryptfs: fix error handling
The error paths and the module exit code need work. sysfs unregistration is not the right place to tear down the crypto subsystem, and the code to undo subsystem initializations on various error paths is unnecessarily duplicated. This patch addresses those issues. Signed-off-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')
-rw-r--r--fs/ecryptfs/main.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 00686f1c5997..49545951912f 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -799,13 +799,6 @@ out:
799 799
800static void do_sysfs_unregistration(void) 800static void do_sysfs_unregistration(void)
801{ 801{
802 int rc;
803
804 rc = ecryptfs_destroy_crypto();
805 if (rc) {
806 printk(KERN_ERR "Failure whilst attempting to destroy crypto; "
807 "rc = [%d]\n", rc);
808 }
809 sysfs_remove_file(&ecryptfs_subsys.kobj, 802 sysfs_remove_file(&ecryptfs_subsys.kobj,
810 &sysfs_attr_version.attr); 803 &sysfs_attr_version.attr);
811 sysfs_remove_file(&ecryptfs_subsys.kobj, 804 sysfs_remove_file(&ecryptfs_subsys.kobj,
@@ -836,43 +829,49 @@ static int __init ecryptfs_init(void)
836 rc = register_filesystem(&ecryptfs_fs_type); 829 rc = register_filesystem(&ecryptfs_fs_type);
837 if (rc) { 830 if (rc) {
838 printk(KERN_ERR "Failed to register filesystem\n"); 831 printk(KERN_ERR "Failed to register filesystem\n");
839 ecryptfs_free_kmem_caches(); 832 goto out_free_kmem_caches;
840 goto out;
841 } 833 }
842 kobj_set_kset_s(&ecryptfs_subsys, fs_subsys); 834 kobj_set_kset_s(&ecryptfs_subsys, fs_subsys);
843 rc = do_sysfs_registration(); 835 rc = do_sysfs_registration();
844 if (rc) { 836 if (rc) {
845 printk(KERN_ERR "sysfs registration failed\n"); 837 printk(KERN_ERR "sysfs registration failed\n");
846 unregister_filesystem(&ecryptfs_fs_type); 838 goto out_unregister_filesystem;
847 ecryptfs_free_kmem_caches();
848 goto out;
849 } 839 }
850 rc = ecryptfs_init_messaging(ecryptfs_transport); 840 rc = ecryptfs_init_messaging(ecryptfs_transport);
851 if (rc) { 841 if (rc) {
852 ecryptfs_printk(KERN_ERR, "Failure occured while attempting to " 842 ecryptfs_printk(KERN_ERR, "Failure occured while attempting to "
853 "initialize the eCryptfs netlink socket\n"); 843 "initialize the eCryptfs netlink socket\n");
854 do_sysfs_unregistration(); 844 goto out_do_sysfs_unregistration;
855 unregister_filesystem(&ecryptfs_fs_type);
856 ecryptfs_free_kmem_caches();
857 goto out;
858 } 845 }
859 rc = ecryptfs_init_crypto(); 846 rc = ecryptfs_init_crypto();
860 if (rc) { 847 if (rc) {
861 printk(KERN_ERR "Failure whilst attempting to init crypto; " 848 printk(KERN_ERR "Failure whilst attempting to init crypto; "
862 "rc = [%d]\n", rc); 849 "rc = [%d]\n", rc);
863 do_sysfs_unregistration(); 850 goto out_release_messaging;
864 unregister_filesystem(&ecryptfs_fs_type);
865 ecryptfs_free_kmem_caches();
866 goto out;
867 } 851 }
852 goto out;
853out_release_messaging:
854 ecryptfs_release_messaging(ecryptfs_transport);
855out_do_sysfs_unregistration:
856 do_sysfs_unregistration();
857out_unregister_filesystem:
858 unregister_filesystem(&ecryptfs_fs_type);
859out_free_kmem_caches:
860 ecryptfs_free_kmem_caches();
868out: 861out:
869 return rc; 862 return rc;
870} 863}
871 864
872static void __exit ecryptfs_exit(void) 865static void __exit ecryptfs_exit(void)
873{ 866{
874 do_sysfs_unregistration(); 867 int rc;
868
869 rc = ecryptfs_destroy_crypto();
870 if (rc)
871 printk(KERN_ERR "Failure whilst attempting to destroy crypto; "
872 "rc = [%d]\n", rc);
875 ecryptfs_release_messaging(ecryptfs_transport); 873 ecryptfs_release_messaging(ecryptfs_transport);
874 do_sysfs_unregistration();
876 unregister_filesystem(&ecryptfs_fs_type); 875 unregister_filesystem(&ecryptfs_fs_type);
877 ecryptfs_free_kmem_caches(); 876 ecryptfs_free_kmem_caches();
878} 877}