Commit 563ca40d authored by Kees Cook's avatar Kees Cook

pstore/platform: Switch pstore_info::name to const

In order to more cleanly pass around backend names, make the "name" member
const. This means the module param needs to be dynamic (technically, it
was before, so this actually cleans up a minor memory leak if a backend
was specified and then gets unloaded.)

Link: https://lore.kernel.org/lkml/20200510202436.63222-3-keescook@chromium.org/Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent b7753fc7
...@@ -624,7 +624,7 @@ int pstore_register(struct pstore_info *psi) ...@@ -624,7 +624,7 @@ int pstore_register(struct pstore_info *psi)
* Update the module parameter backend, so it is visible * Update the module parameter backend, so it is visible
* through /sys/module/pstore/parameters/backend * through /sys/module/pstore/parameters/backend
*/ */
backend = psi->name; backend = kstrdup(psi->name, GFP_KERNEL);
pr_info("Registered %s as persistent store backend\n", psi->name); pr_info("Registered %s as persistent store backend\n", psi->name);
...@@ -667,6 +667,7 @@ void pstore_unregister(struct pstore_info *psi) ...@@ -667,6 +667,7 @@ void pstore_unregister(struct pstore_info *psi)
free_buf_for_compression(); free_buf_for_compression();
psinfo = NULL; psinfo = NULL;
kfree(backend);
backend = NULL; backend = NULL;
mutex_unlock(&psinfo_lock); mutex_unlock(&psinfo_lock);
} }
......
...@@ -170,7 +170,7 @@ struct pstore_record { ...@@ -170,7 +170,7 @@ struct pstore_record {
*/ */
struct pstore_info { struct pstore_info {
struct module *owner; struct module *owner;
char *name; const char *name;
struct semaphore buf_lock; struct semaphore buf_lock;
char *buf; char *buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment