]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/pstore-centralize-init-exit-routines.patch
2e62bde73a175faaeb3d909bd756da6acb8cf803
[thirdparty/kernel/stable-queue.git] / queue-4.19 / pstore-centralize-init-exit-routines.patch
1 From cb095afd44768bf495894b9ad063bd078e4bb201 Mon Sep 17 00:00:00 2001
2 From: Kees Cook <keescook@chromium.org>
3 Date: Thu, 18 Oct 2018 11:17:42 -0700
4 Subject: pstore: Centralize init/exit routines
5
6 From: Kees Cook <keescook@chromium.org>
7
8 commit cb095afd44768bf495894b9ad063bd078e4bb201 upstream.
9
10 In preparation for having additional actions during init/exit, this moves
11 the init/exit into platform.c, centralizing the logic to make call outs
12 to the fs init/exit.
13
14 Signed-off-by: Kees Cook <keescook@chromium.org>
15 Tested-by: Guenter Roeck <groeck@chromium.org>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17
18 ---
19 fs/pstore/inode.c | 11 ++---------
20 fs/pstore/internal.h | 5 +++--
21 fs/pstore/platform.c | 23 +++++++++++++++++++++++
22 3 files changed, 28 insertions(+), 11 deletions(-)
23
24 --- a/fs/pstore/inode.c
25 +++ b/fs/pstore/inode.c
26 @@ -482,12 +482,10 @@ static struct file_system_type pstore_fs
27 .kill_sb = pstore_kill_sb,
28 };
29
30 -static int __init init_pstore_fs(void)
31 +int __init pstore_init_fs(void)
32 {
33 int err;
34
35 - pstore_choose_compression();
36 -
37 /* Create a convenient mount point for people to access pstore */
38 err = sysfs_create_mount_point(fs_kobj, "pstore");
39 if (err)
40 @@ -500,14 +498,9 @@ static int __init init_pstore_fs(void)
41 out:
42 return err;
43 }
44 -module_init(init_pstore_fs)
45
46 -static void __exit exit_pstore_fs(void)
47 +void __exit pstore_exit_fs(void)
48 {
49 unregister_filesystem(&pstore_fs_type);
50 sysfs_remove_mount_point(fs_kobj, "pstore");
51 }
52 -module_exit(exit_pstore_fs)
53 -
54 -MODULE_AUTHOR("Tony Luck <tony.luck@intel.com>");
55 -MODULE_LICENSE("GPL");
56 --- a/fs/pstore/internal.h
57 +++ b/fs/pstore/internal.h
58 @@ -37,7 +37,8 @@ extern bool pstore_is_mounted(void);
59 extern void pstore_record_init(struct pstore_record *record,
60 struct pstore_info *psi);
61
62 -/* Called during module_init() */
63 -extern void __init pstore_choose_compression(void);
64 +/* Called during pstore init/exit. */
65 +int __init pstore_init_fs(void);
66 +void __exit pstore_exit_fs(void);
67
68 #endif
69 --- a/fs/pstore/platform.c
70 +++ b/fs/pstore/platform.c
71 @@ -780,8 +780,31 @@ void __init pstore_choose_compression(vo
72 }
73 }
74
75 +static int __init pstore_init(void)
76 +{
77 + int ret;
78 +
79 + pstore_choose_compression();
80 +
81 + ret = pstore_init_fs();
82 + if (ret)
83 + return ret;
84 +
85 + return 0;
86 +}
87 +module_init(pstore_init)
88 +
89 +static void __exit pstore_exit(void)
90 +{
91 + pstore_exit_fs();
92 +}
93 +module_exit(pstore_exit)
94 +
95 module_param(compress, charp, 0444);
96 MODULE_PARM_DESC(compress, "Pstore compression to use");
97
98 module_param(backend, charp, 0444);
99 MODULE_PARM_DESC(backend, "Pstore backend to use");
100 +
101 +MODULE_AUTHOR("Tony Luck <tony.luck@intel.com>");
102 +MODULE_LICENSE("GPL");