binfmt_misc: fix crash when load/unload module
[linux-2.6-block.git] / fs / binfmt_misc.c
index ddea6acbddde5f1622243c6c8c706be679e28f90..c07f35719ee3fdc893a2e17a36d31b9360ff655f 100644 (file)
@@ -817,20 +817,20 @@ static struct file_system_type bm_fs_type = {
 };
 MODULE_ALIAS_FS("binfmt_misc");
 
+static struct ctl_table_header *binfmt_misc_header;
+
 static int __init init_misc_binfmt(void)
 {
        int err = register_filesystem(&bm_fs_type);
        if (!err)
                insert_binfmt(&misc_format);
-       if (!register_sysctl_mount_point("fs/binfmt_misc")) {
-               pr_warn("Failed to create fs/binfmt_misc sysctl mount point");
-               return -ENOMEM;
-       }
+       binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
        return 0;
 }
 
 static void __exit exit_misc_binfmt(void)
 {
+       unregister_sysctl_table(binfmt_misc_header);
        unregister_binfmt(&misc_format);
        unregister_filesystem(&bm_fs_type);
 }