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