diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-10-29 12:18:20 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-10-29 12:18:20 -0400 |
| commit | 9532faeb293f5a5f0ff06f567de14e557698dbde (patch) | |
| tree | 46319ff2506340b56b34801e3a722bbaf28d55bf /kernel/params.c | |
| parent | add810a1c58ba9edb6076ababe5861f36c049217 (diff) | |
| parent | 3c7d76e371ac1a3802ae1673f5c63554af59325c (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-param-fixes
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-param-fixes:
param: fix setting arrays of bool
param: fix NULL comparison on oom
param: fix lots of bugs with writing charp params from sysfs, by leaking mem.
Diffstat (limited to 'kernel/params.c')
| -rw-r--r-- | kernel/params.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/kernel/params.c b/kernel/params.c index 9da58eabdcb2..d656c276508d 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
| @@ -218,15 +218,11 @@ int param_set_charp(const char *val, struct kernel_param *kp) | |||
| 218 | return -ENOSPC; | 218 | return -ENOSPC; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | if (kp->flags & KPARAM_KMALLOCED) | ||
| 222 | kfree(*(char **)kp->arg); | ||
| 223 | |||
| 224 | /* This is a hack. We can't need to strdup in early boot, and we | 221 | /* This is a hack. We can't need to strdup in early boot, and we |
| 225 | * don't need to; this mangled commandline is preserved. */ | 222 | * don't need to; this mangled commandline is preserved. */ |
| 226 | if (slab_is_available()) { | 223 | if (slab_is_available()) { |
| 227 | kp->flags |= KPARAM_KMALLOCED; | ||
| 228 | *(char **)kp->arg = kstrdup(val, GFP_KERNEL); | 224 | *(char **)kp->arg = kstrdup(val, GFP_KERNEL); |
| 229 | if (!kp->arg) | 225 | if (!*(char **)kp->arg) |
| 230 | return -ENOMEM; | 226 | return -ENOMEM; |
| 231 | } else | 227 | } else |
| 232 | *(const char **)kp->arg = val; | 228 | *(const char **)kp->arg = val; |
| @@ -304,6 +300,7 @@ static int param_array(const char *name, | |||
| 304 | unsigned int min, unsigned int max, | 300 | unsigned int min, unsigned int max, |
| 305 | void *elem, int elemsize, | 301 | void *elem, int elemsize, |
| 306 | int (*set)(const char *, struct kernel_param *kp), | 302 | int (*set)(const char *, struct kernel_param *kp), |
| 303 | u16 flags, | ||
| 307 | unsigned int *num) | 304 | unsigned int *num) |
| 308 | { | 305 | { |
| 309 | int ret; | 306 | int ret; |
| @@ -313,6 +310,7 @@ static int param_array(const char *name, | |||
| 313 | /* Get the name right for errors. */ | 310 | /* Get the name right for errors. */ |
| 314 | kp.name = name; | 311 | kp.name = name; |
| 315 | kp.arg = elem; | 312 | kp.arg = elem; |
| 313 | kp.flags = flags; | ||
| 316 | 314 | ||
| 317 | /* No equals sign? */ | 315 | /* No equals sign? */ |
| 318 | if (!val) { | 316 | if (!val) { |
| @@ -358,7 +356,8 @@ int param_array_set(const char *val, struct kernel_param *kp) | |||
| 358 | unsigned int temp_num; | 356 | unsigned int temp_num; |
| 359 | 357 | ||
| 360 | return param_array(kp->name, val, 1, arr->max, arr->elem, | 358 | return param_array(kp->name, val, 1, arr->max, arr->elem, |
| 361 | arr->elemsize, arr->set, arr->num ?: &temp_num); | 359 | arr->elemsize, arr->set, kp->flags, |
| 360 | arr->num ?: &temp_num); | ||
| 362 | } | 361 | } |
| 363 | 362 | ||
| 364 | int param_array_get(char *buffer, struct kernel_param *kp) | 363 | int param_array_get(char *buffer, struct kernel_param *kp) |
| @@ -605,11 +604,7 @@ void module_param_sysfs_remove(struct module *mod) | |||
| 605 | 604 | ||
| 606 | void destroy_params(const struct kernel_param *params, unsigned num) | 605 | void destroy_params(const struct kernel_param *params, unsigned num) |
| 607 | { | 606 | { |
| 608 | unsigned int i; | 607 | /* FIXME: This should free kmalloced charp parameters. It doesn't. */ |
| 609 | |||
| 610 | for (i = 0; i < num; i++) | ||
| 611 | if (params[i].flags & KPARAM_KMALLOCED) | ||
| 612 | kfree(*(char **)params[i].arg); | ||
| 613 | } | 608 | } |
| 614 | 609 | ||
| 615 | static void __init kernel_add_sysfs_param(const char *name, | 610 | static void __init kernel_add_sysfs_param(const char *name, |
