* 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.
Unified · Split
| @@ -37,7 +37,6 @@ typedef int (*param_set_fn)(const char *val, struct kernel_param *kp); · 36 unmodified lines | ||
| 37 | 37 | typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp); |
| 38 | 38 | |
| 39 | 39 | /* Flag bits for kernel_param.flags */ |
| 40 | −#define KPARAM_KMALLOCED 1 | |
| 41 | 40 | #define KPARAM_ISBOOL 2 |
| 42 | 41 | |
| 43 | 42 | struct kernel_param { |
| @@ -218,15 +218,11 @@ int param_set_charp(const char *val, struct kernel_param *kp) · 217 unmodified lines | ||
| 218 | 218 | return -ENOSPC; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | − if (kp->flags & KPARAM_KMALLOCED) | |
| 222 | − kfree(*(char **)kp->arg); | |
| 223 | − | |
| 224 | 221 | /* This is a hack. We can't need to strdup in early boot, and we |
| 225 | 222 | * don't need to; this mangled commandline is preserved. */ |
| 226 | 223 | if (slab_is_available()) { |
| 227 | − kp->flags |= KPARAM_KMALLOCED; | |
| 228 | 224 | *(char **)kp->arg = kstrdup(val, GFP_KERNEL); |
| 229 | − if (!kp->arg) | |
| 225 | + if (!*(char **)kp->arg) | |
| 230 | 226 | return -ENOMEM; |
| 231 | 227 | } else |
| 232 | 228 | *(const char **)kp->arg = val; |
| @@ -304,6 +300,7 @@ static int param_array(const char *name, · 71 unmodified lines | ||
| 304 | 300 | unsigned int min, unsigned int max, |
| 305 | 301 | void *elem, int elemsize, |
| 306 | 302 | int (*set)(const char *, struct kernel_param *kp), |
| 303 | + u16 flags, | |
| 307 | 304 | unsigned int *num) |
| 308 | 305 | { |
| 309 | 306 | int ret; |
| @@ -313,6 +310,7 @@ static int param_array(const char *name, · 3 unmodified lines | ||
| 313 | 310 | /* Get the name right for errors. */ |
| 314 | 311 | kp.name = name; |
| 315 | 312 | kp.arg = elem; |
| 313 | + kp.flags = flags; | |
| 316 | 314 | |
| 317 | 315 | /* No equals sign? */ |
| 318 | 316 | if (!val) { |
| @@ -358,7 +356,8 @@ int param_array_set(const char *val, struct kernel_param *kp) · 39 unmodified lines | ||
| 358 | 356 | unsigned int temp_num; |
| 359 | 357 | |
| 360 | 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 | 363 | int param_array_get(char *buffer, struct kernel_param *kp) |
| @@ -605,11 +604,7 @@ void module_param_sysfs_remove(struct module *mod) · 240 unmodified lines | ||
| 605 | 604 | |
| 606 | 605 | void destroy_params(const struct kernel_param *params, unsigned num) |
| 607 | 606 | { |
| 608 | − unsigned int i; | |
| 609 | − | |
| 610 | − for (i = 0; i < num; i++) | |
| 611 | − if (params[i].flags & KPARAM_KMALLOCED) | |
| 612 | − kfree(*(char **)params[i].arg); | |
| 607 | + /* FIXME: This should free kmalloced charp parameters. It doesn't. */ | |
| 613 | 608 | } |
| 614 | 609 | |
| 615 | 610 | static void __init kernel_add_sysfs_param(const char *name, |