diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-05 13:30:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-05 13:30:21 -0400 |
commit | cab4e4c43f92582a2bfc026137b3d8a175bd0360 (patch) | |
tree | 2f0e8fbc2e7d2d0cd6f1658a5e084a53b1e83a2e /kernel/params.c | |
parent | 5412b5399e095730008a14f2107331b2123733e4 (diff) | |
parent | 49502677e11079c2e3e01867c922a894ce06a8be (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param:
module: use strstarts()
strstarts: helper function for !strncmp(str, prefix, strlen(prefix))
arm: allow usage of string functions in linux/string.h
module: don't use stop_machine on module load
module: create a request_module_nowait()
module: include other structures in module version check
module: remove the SHF_ALLOC flag on the __versions section.
module: clarify the force-loading taint message.
module: Export symbols needed for Ksplice
Ksplice: Add functions for walking kallsyms symbols
module: remove module_text_address()
module: __module_address
module: Make find_symbol return a struct kernel_symbol
kernel/module.c: fix an unused goto label
param: fix charp parameters set via sysfs
Fix trivial conflicts in kernel/extable.c manually.
Diffstat (limited to 'kernel/params.c')
-rw-r--r-- | kernel/params.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/kernel/params.c b/kernel/params.c index a1e3025b19a9..de273ec85bd2 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -24,6 +24,9 @@ | |||
24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | 26 | ||
27 | /* We abuse the high bits of "perm" to record whether we kmalloc'ed. */ | ||
28 | #define KPARAM_KMALLOCED 0x80000000 | ||
29 | |||
27 | #if 0 | 30 | #if 0 |
28 | #define DEBUGP printk | 31 | #define DEBUGP printk |
29 | #else | 32 | #else |
@@ -217,7 +220,19 @@ int param_set_charp(const char *val, struct kernel_param *kp) | |||
217 | return -ENOSPC; | 220 | return -ENOSPC; |
218 | } | 221 | } |
219 | 222 | ||
220 | *(char **)kp->arg = (char *)val; | 223 | if (kp->perm & KPARAM_KMALLOCED) |
224 | kfree(*(char **)kp->arg); | ||
225 | |||
226 | /* This is a hack. We can't need to strdup in early boot, and we | ||
227 | * don't need to; this mangled commandline is preserved. */ | ||
228 | if (slab_is_available()) { | ||
229 | kp->perm |= KPARAM_KMALLOCED; | ||
230 | *(char **)kp->arg = kstrdup(val, GFP_KERNEL); | ||
231 | if (!kp->arg) | ||
232 | return -ENOMEM; | ||
233 | } else | ||
234 | *(const char **)kp->arg = val; | ||
235 | |||
221 | return 0; | 236 | return 0; |
222 | } | 237 | } |
223 | 238 | ||
@@ -571,6 +586,15 @@ void module_param_sysfs_remove(struct module *mod) | |||
571 | } | 586 | } |
572 | #endif | 587 | #endif |
573 | 588 | ||
589 | void destroy_params(const struct kernel_param *params, unsigned num) | ||
590 | { | ||
591 | unsigned int i; | ||
592 | |||
593 | for (i = 0; i < num; i++) | ||
594 | if (params[i].perm & KPARAM_KMALLOCED) | ||
595 | kfree(*(char **)params[i].arg); | ||
596 | } | ||
597 | |||
574 | static void __init kernel_add_sysfs_param(const char *name, | 598 | static void __init kernel_add_sysfs_param(const char *name, |
575 | struct kernel_param *kparam, | 599 | struct kernel_param *kparam, |
576 | unsigned int name_skip) | 600 | unsigned int name_skip) |