diff options
| author | Petr Pavlu <petr.pavlu@suse.com> | 2026-03-13 14:48:02 +0100 |
|---|---|---|
| committer | Sami Tolvanen <samitolvanen@google.com> | 2026-03-18 21:43:18 +0000 |
| commit | deffe1edba626d474fef38007c03646ca5876a0e (patch) | |
| tree | 113de16495393340dc12e1891e4b5c181644ead1 /include/linux/moduleparam.h | |
| parent | 4afc71bba8b7d7841681e7647ae02f5079aaf28f (diff) | |
| download | lwn-deffe1edba626d474fef38007c03646ca5876a0e.tar.gz lwn-deffe1edba626d474fef38007c03646ca5876a0e.zip | |
module: Fix freeing of charp module parameters when CONFIG_SYSFS=n
When setting a charp module parameter, the param_set_charp() function
allocates memory to store a copy of the input value. Later, when the module
is potentially unloaded, the destroy_params() function is called to free
this allocated memory.
However, destroy_params() is available only when CONFIG_SYSFS=y, otherwise
only a dummy variant is present. In the unlikely case that the kernel is
configured with CONFIG_MODULES=y and CONFIG_SYSFS=n, this results in
a memory leak of charp values when a module is unloaded.
Fix this issue by making destroy_params() always available when
CONFIG_MODULES=y. Rename the function to module_destroy_params() to clarify
that it is intended for use by the module loader.
Fixes: e180a6b7759a ("param: fix charp parameters set via sysfs")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Diffstat (limited to 'include/linux/moduleparam.h')
| -rw-r--r-- | include/linux/moduleparam.h | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 7d22d4c4ea2e..8667f72503d9 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -426,14 +426,9 @@ extern char *parse_args(const char *name, void *arg, parse_unknown_fn unknown); /* Called by module remove. */ -#ifdef CONFIG_SYSFS -extern void destroy_params(const struct kernel_param *params, unsigned num); -#else -static inline void destroy_params(const struct kernel_param *params, - unsigned num) -{ -} -#endif /* !CONFIG_SYSFS */ +#ifdef CONFIG_MODULES +void module_destroy_params(const struct kernel_param *params, unsigned int num); +#endif /* All the helper functions */ /* The macros to do compile-time type checking stolen from Jakub |
