aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/pstore/ram.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index bbd1e357c23d..f4fd2e72add4 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -898,8 +898,22 @@ static struct platform_driver ramoops_driver = {
898 }, 898 },
899}; 899};
900 900
901static void ramoops_register_dummy(void) 901static inline void ramoops_unregister_dummy(void)
902{ 902{
903 platform_device_unregister(dummy);
904 dummy = NULL;
905
906 kfree(dummy_data);
907 dummy_data = NULL;
908}
909
910static void __init ramoops_register_dummy(void)
911{
912 /*
913 * Prepare a dummy platform data structure to carry the module
914 * parameters. If mem_size isn't set, then there are no module
915 * parameters, and we can skip this.
916 */
903 if (!mem_size) 917 if (!mem_size)
904 return; 918 return;
905 919
@@ -932,21 +946,28 @@ static void ramoops_register_dummy(void)
932 if (IS_ERR(dummy)) { 946 if (IS_ERR(dummy)) {
933 pr_info("could not create platform device: %ld\n", 947 pr_info("could not create platform device: %ld\n",
934 PTR_ERR(dummy)); 948 PTR_ERR(dummy));
949 dummy = NULL;
950 ramoops_unregister_dummy();
935 } 951 }
936} 952}
937 953
938static int __init ramoops_init(void) 954static int __init ramoops_init(void)
939{ 955{
956 int ret;
957
940 ramoops_register_dummy(); 958 ramoops_register_dummy();
941 return platform_driver_register(&ramoops_driver); 959 ret = platform_driver_register(&ramoops_driver);
960 if (ret != 0)
961 ramoops_unregister_dummy();
962
963 return ret;
942} 964}
943late_initcall(ramoops_init); 965late_initcall(ramoops_init);
944 966
945static void __exit ramoops_exit(void) 967static void __exit ramoops_exit(void)
946{ 968{
947 platform_driver_unregister(&ramoops_driver); 969 platform_driver_unregister(&ramoops_driver);
948 platform_device_unregister(dummy); 970 ramoops_unregister_dummy();
949 kfree(dummy_data);
950} 971}
951module_exit(ramoops_exit); 972module_exit(ramoops_exit);
952 973