Skip to content

Commit 563ca40

Browse files
committed
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/[email protected]/ Signed-off-by: Kees Cook <[email protected]>
1 parent b7753fc commit 563ca40

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

fs/pstore/platform.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ int pstore_register(struct pstore_info *psi)
624624
* Update the module parameter backend, so it is visible
625625
* through /sys/module/pstore/parameters/backend
626626
*/
627-
backend = psi->name;
627+
backend = kstrdup(psi->name, GFP_KERNEL);
628628

629629
pr_info("Registered %s as persistent store backend\n", psi->name);
630630

@@ -667,6 +667,7 @@ void pstore_unregister(struct pstore_info *psi)
667667
free_buf_for_compression();
668668

669669
psinfo = NULL;
670+
kfree(backend);
670671
backend = NULL;
671672
mutex_unlock(&psinfo_lock);
672673
}

include/linux/pstore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct pstore_record {
170170
*/
171171
struct pstore_info {
172172
struct module *owner;
173-
char *name;
173+
const char *name;
174174

175175
struct semaphore buf_lock;
176176
char *buf;

0 commit comments

Comments
 (0)