Skip to content

Commit

Permalink
pstore/platform: Switch pstore_info::name to const
Browse files Browse the repository at this point in the history
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/[email protected]/
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
kees committed May 30, 2020
1 parent b7753fc commit 563ca40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ int pstore_register(struct pstore_info *psi)
* Update the module parameter backend, so it is visible
* 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);

Expand Down Expand Up @@ -667,6 +667,7 @@ void pstore_unregister(struct pstore_info *psi)
free_buf_for_compression();

psinfo = NULL;
kfree(backend);
backend = NULL;
mutex_unlock(&psinfo_lock);
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/pstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ struct pstore_record {
*/
struct pstore_info {
struct module *owner;
char *name;
const char *name;

struct semaphore buf_lock;
char *buf;
Expand Down

0 comments on commit 563ca40

Please sign in to comment.