diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-11-25 13:16:20 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2009-11-25 13:16:20 +1100 |
commit | 9113951fcc54d4b38d0c3063d44fb3d836183462 (patch) | |
tree | 0ea1611ed837b9db50f21541b6975e5be50b4dd1 /kernel | |
parent | 9b2c4d3cddc0fbd077bfdb18d91b668545f6d7ed (diff) |
param:add-free-hook
This allows us to generalize the KPARAM_KMALLOCED flag, by calling a function
on every parameter when a module is unloaded.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/params.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/kernel/params.c b/kernel/params.c index b51e3d0dbb79..577f94587bbf 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -412,9 +412,20 @@ static int param_array_get(char *buffer, const struct kernel_param *kp) return off; } +static void param_array_free(void *arg) +{ + unsigned int i; + const struct kparam_array *arr = arg; + + if (arr->ops->free) + for (i = 0; i < (arr->num ? *arr->num : arr->max); i++) + arr->ops->free(arr->elem + arr->elemsize * i); +} + struct kernel_param_ops param_array_ops = { .set = param_array_set, .get = param_array_get, + .free = param_array_free, }; EXPORT_SYMBOL(param_array_ops); @@ -650,7 +661,11 @@ void module_param_sysfs_remove(struct module *mod) void destroy_params(const struct kernel_param *params, unsigned num) { - /* FIXME: This should free kmalloced charp parameters. It doesn't. */ + unsigned int i; + + for (i = 0; i < num; i++) + if (params[i].ops->free) + params[i].ops->free(params[i].arg); } static void __init kernel_add_sysfs_param(const char *name, |