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