History

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.

Linus Torvalds committed 17 years ago

Commit 9532fae2 parents add810a 3c7d76e2 files · +6 −12Browse files

Showing the changes to kernel (1 of 2 files). Show all

Unified · Split

kernel/params.c+6−11
@@ -218,15 +218,11 @@ int param_set_charp(const char *val, struct kernel_param *kp) · 217 unmodified lines
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 we221 /* 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 } else227 } else
232 *(const char **)kp->arg = val;228 *(const char **)kp->arg = val;
@@ -304,6 +300,7 @@ static int param_array(const char *name, · 71 unmodified lines
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, · 3 unmodified lines
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) · 39 unmodified lines
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
364int param_array_get(char *buffer, struct kernel_param *kp)363int 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
606void destroy_params(const struct kernel_param *params, unsigned num)605void 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
615static void __init kernel_add_sysfs_param(const char *name,610static void __init kernel_add_sysfs_param(const char *name,