Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Kees Cook <keescook@chromium.org>

+3 -2
+2 -1
fs/pstore/platform.c
··· 624 624 * Update the module parameter backend, so it is visible 625 625 * through /sys/module/pstore/parameters/backend 626 626 */ 627 - backend = psi->name; 627 + backend = kstrdup(psi->name, GFP_KERNEL); 628 628 629 629 pr_info("Registered %s as persistent store backend\n", psi->name); 630 630 ··· 667 667 free_buf_for_compression(); 668 668 669 669 psinfo = NULL; 670 + kfree(backend); 670 671 backend = NULL; 671 672 mutex_unlock(&psinfo_lock); 672 673 }
+1 -1
include/linux/pstore.h
··· 170 170 */ 171 171 struct pstore_info { 172 172 struct module *owner; 173 - char *name; 173 + const char *name; 174 174 175 175 struct semaphore buf_lock; 176 176 char *buf;