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
218218 return -ENOSPC;
219219 }
220220
221− if (kp->flags & KPARAM_KMALLOCED)
222− kfree(*(char **)kp->arg);
223−
224221 /* This is a hack. We can't need to strdup in early boot, and we
225222 * don't need to; this mangled commandline is preserved. */
226223 if (slab_is_available()) {
227− kp->flags |= KPARAM_KMALLOCED;
228224 *(char **)kp->arg = kstrdup(val, GFP_KERNEL);
229− if (!kp->arg)
225+ if (!*(char **)kp->arg)
230226 return -ENOMEM;
231227 } else
232228 *(const char **)kp->arg = val;
@@ -304,6 +300,7 @@ static int param_array(const char *name, · 71 unmodified lines
304300 unsigned int min, unsigned int max,
305301 void *elem, int elemsize,
306302 int (*set)(const char *, struct kernel_param *kp),
303+ u16 flags,
307304 unsigned int *num)
308305 {
309306 int ret;
@@ -313,6 +310,7 @@ static int param_array(const char *name, · 3 unmodified lines
313310 /* Get the name right for errors. */
314311 kp.name = name;
315312 kp.arg = elem;
313+ kp.flags = flags;
316314
317315 /* No equals sign? */
318316 if (!val) {
@@ -358,7 +356,8 @@ int param_array_set(const char *val, struct kernel_param *kp) · 39 unmodified lines
358356 unsigned int temp_num;
359357
360358 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);
362361 }
363362
364363 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
605604
606605 void destroy_params(const struct kernel_param *params, unsigned num)
607606 {
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. */
613608 }
614609
615610 static void __init kernel_add_sysfs_param(const char *name,