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.
This commit is contained in:
commit
9532faeb29
|
@ -37,7 +37,6 @@ typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
|
||||||
typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
|
typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
|
||||||
|
|
||||||
/* Flag bits for kernel_param.flags */
|
/* Flag bits for kernel_param.flags */
|
||||||
#define KPARAM_KMALLOCED 1
|
|
||||||
#define KPARAM_ISBOOL 2
|
#define KPARAM_ISBOOL 2
|
||||||
|
|
||||||
struct kernel_param {
|
struct kernel_param {
|
||||||
|
|
|
@ -218,15 +218,11 @@ int param_set_charp(const char *val, struct kernel_param *kp)
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kp->flags & KPARAM_KMALLOCED)
|
|
||||||
kfree(*(char **)kp->arg);
|
|
||||||
|
|
||||||
/* This is a hack. We can't need to strdup in early boot, and we
|
/* This is a hack. We can't need to strdup in early boot, and we
|
||||||
* don't need to; this mangled commandline is preserved. */
|
* don't need to; this mangled commandline is preserved. */
|
||||||
if (slab_is_available()) {
|
if (slab_is_available()) {
|
||||||
kp->flags |= KPARAM_KMALLOCED;
|
|
||||||
*(char **)kp->arg = kstrdup(val, GFP_KERNEL);
|
*(char **)kp->arg = kstrdup(val, GFP_KERNEL);
|
||||||
if (!kp->arg)
|
if (!*(char **)kp->arg)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
} else
|
} else
|
||||||
*(const char **)kp->arg = val;
|
*(const char **)kp->arg = val;
|
||||||
|
@ -304,6 +300,7 @@ static int param_array(const char *name,
|
||||||
unsigned int min, unsigned int max,
|
unsigned int min, unsigned int max,
|
||||||
void *elem, int elemsize,
|
void *elem, int elemsize,
|
||||||
int (*set)(const char *, struct kernel_param *kp),
|
int (*set)(const char *, struct kernel_param *kp),
|
||||||
|
u16 flags,
|
||||||
unsigned int *num)
|
unsigned int *num)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -313,6 +310,7 @@ static int param_array(const char *name,
|
||||||
/* Get the name right for errors. */
|
/* Get the name right for errors. */
|
||||||
kp.name = name;
|
kp.name = name;
|
||||||
kp.arg = elem;
|
kp.arg = elem;
|
||||||
|
kp.flags = flags;
|
||||||
|
|
||||||
/* No equals sign? */
|
/* No equals sign? */
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
@ -358,7 +356,8 @@ int param_array_set(const char *val, struct kernel_param *kp)
|
||||||
unsigned int temp_num;
|
unsigned int temp_num;
|
||||||
|
|
||||||
return param_array(kp->name, val, 1, arr->max, arr->elem,
|
return param_array(kp->name, val, 1, arr->max, arr->elem,
|
||||||
arr->elemsize, arr->set, arr->num ?: &temp_num);
|
arr->elemsize, arr->set, kp->flags,
|
||||||
|
arr->num ?: &temp_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
int param_array_get(char *buffer, struct kernel_param *kp)
|
int param_array_get(char *buffer, struct kernel_param *kp)
|
||||||
|
@ -605,11 +604,7 @@ void module_param_sysfs_remove(struct module *mod)
|
||||||
|
|
||||||
void destroy_params(const struct kernel_param *params, unsigned num)
|
void destroy_params(const struct kernel_param *params, unsigned num)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
/* FIXME: This should free kmalloced charp parameters. It doesn't. */
|
||||||
|
|
||||||
for (i = 0; i < num; i++)
|
|
||||||
if (params[i].flags & KPARAM_KMALLOCED)
|
|
||||||
kfree(*(char **)params[i].arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init kernel_add_sysfs_param(const char *name,
|
static void __init kernel_add_sysfs_param(const char *name,
|
||||||
|
|
Loading…
Reference in New Issue