aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/params.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/params.c')
-rw-r--r--kernel/params.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/kernel/params.c b/kernel/params.c
index 9da58eabdcb..cf1b6918312 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -24,6 +24,7 @@
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/ctype.h> 26#include <linux/ctype.h>
27#include <linux/string.h>
27 28
28#if 0 29#if 0
29#define DEBUGP printk 30#define DEBUGP printk
@@ -122,9 +123,7 @@ static char *next_arg(char *args, char **param, char **val)
122 next = args + i; 123 next = args + i;
123 124
124 /* Chew up trailing spaces. */ 125 /* Chew up trailing spaces. */
125 while (isspace(*next)) 126 return skip_spaces(next);
126 next++;
127 return next;
128} 127}
129 128
130/* Args looks like "foo=bar,bar2 baz=fuz wiz". */ 129/* Args looks like "foo=bar,bar2 baz=fuz wiz". */
@@ -139,8 +138,7 @@ int parse_args(const char *name,
139 DEBUGP("Parsing ARGS: %s\n", args); 138 DEBUGP("Parsing ARGS: %s\n", args);
140 139
141 /* Chew leading spaces */ 140 /* Chew leading spaces */
142 while (isspace(*args)) 141 args = skip_spaces(args);
143 args++;
144 142
145 while (*args) { 143 while (*args) {
146 int ret; 144 int ret;
@@ -218,15 +216,11 @@ int param_set_charp(const char *val, struct kernel_param *kp)
218 return -ENOSPC; 216 return -ENOSPC;
219 } 217 }
220 218
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 219 /* 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. */ 220 * don't need to; this mangled commandline is preserved. */
226 if (slab_is_available()) { 221 if (slab_is_available()) {
227 kp->flags |= KPARAM_KMALLOCED;
228 *(char **)kp->arg = kstrdup(val, GFP_KERNEL); 222 *(char **)kp->arg = kstrdup(val, GFP_KERNEL);
229 if (!kp->arg) 223 if (!*(char **)kp->arg)
230 return -ENOMEM; 224 return -ENOMEM;
231 } else 225 } else
232 *(const char **)kp->arg = val; 226 *(const char **)kp->arg = val;
@@ -304,6 +298,7 @@ static int param_array(const char *name,
304 unsigned int min, unsigned int max, 298 unsigned int min, unsigned int max,
305 void *elem, int elemsize, 299 void *elem, int elemsize,
306 int (*set)(const char *, struct kernel_param *kp), 300 int (*set)(const char *, struct kernel_param *kp),
301 u16 flags,
307 unsigned int *num) 302 unsigned int *num)
308{ 303{
309 int ret; 304 int ret;
@@ -313,6 +308,7 @@ static int param_array(const char *name,
313 /* Get the name right for errors. */ 308 /* Get the name right for errors. */
314 kp.name = name; 309 kp.name = name;
315 kp.arg = elem; 310 kp.arg = elem;
311 kp.flags = flags;
316 312
317 /* No equals sign? */ 313 /* No equals sign? */
318 if (!val) { 314 if (!val) {
@@ -358,7 +354,8 @@ int param_array_set(const char *val, struct kernel_param *kp)
358 unsigned int temp_num; 354 unsigned int temp_num;
359 355
360 return param_array(kp->name, val, 1, arr->max, arr->elem, 356 return param_array(kp->name, val, 1, arr->max, arr->elem,
361 arr->elemsize, arr->set, arr->num ?: &temp_num); 357 arr->elemsize, arr->set, kp->flags,
358 arr->num ?: &temp_num);
362} 359}
363 360
364int param_array_get(char *buffer, struct kernel_param *kp) 361int param_array_get(char *buffer, struct kernel_param *kp)
@@ -605,11 +602,7 @@ void module_param_sysfs_remove(struct module *mod)
605 602
606void destroy_params(const struct kernel_param *params, unsigned num) 603void destroy_params(const struct kernel_param *params, unsigned num)
607{ 604{
608 unsigned int i; 605 /* 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} 606}
614 607
615static void __init kernel_add_sysfs_param(const char *name, 608static void __init kernel_add_sysfs_param(const char *name,