diff options
author | Borislav Petkov <borislav.petkov@amd.com> | 2012-09-10 16:50:54 +0200 |
---|---|---|
committer | Borislav Petkov <bp@alien8.de> | 2012-11-28 11:23:32 +0100 |
commit | 37929874d439d79e8f6128f400f63069ee1bbf3e (patch) | |
tree | b0f8ac80ab7b804a03a47a0bb1457dfe2a39effc /drivers/edac/edac_module.c | |
parent | 876bb331e26b970c2d8caea2c1d1209fdae953d0 (diff) | |
download | blackbird-op-linux-37929874d439d79e8f6128f400f63069ee1bbf3e.tar.gz blackbird-op-linux-37929874d439d79e8f6128f400f63069ee1bbf3e.zip |
EDAC: Boundary-check edac_debug_level
Only levels [0:4] are allowed so enforce that. Also, while at it,
massage Kconfig text and add valid debug levels range to the module
parameter description.
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac/edac_module.c')
-rw-r--r-- | drivers/edac/edac_module.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c index 58a28d838f37..12c951a2c33d 100644 --- a/drivers/edac/edac_module.c +++ b/drivers/edac/edac_module.c @@ -18,9 +18,29 @@ #define EDAC_VERSION "Ver: 3.0.0" #ifdef CONFIG_EDAC_DEBUG + +static int edac_set_debug_level(const char *buf, struct kernel_param *kp) +{ + unsigned long val; + int ret; + + ret = kstrtoul(buf, 0, &val); + if (ret) + return ret; + + if (val < 0 || val > 4) + return -EINVAL; + + return param_set_int(buf, kp); +} + /* Values of 0 to 4 will generate output */ int edac_debug_level = 2; EXPORT_SYMBOL_GPL(edac_debug_level); + +module_param_call(edac_debug_level, edac_set_debug_level, param_get_int, + &edac_debug_level, 0644); +MODULE_PARM_DESC(edac_debug_level, "EDAC debug level: [0-4], default: 2"); #endif /* scope is to module level only */ @@ -132,10 +152,3 @@ module_exit(edac_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Doug Thompson www.softwarebitmaker.com, et al"); MODULE_DESCRIPTION("Core library routines for EDAC reporting"); - -/* refer to *_sysfs.c files for parameters that are exported via sysfs */ - -#ifdef CONFIG_EDAC_DEBUG -module_param(edac_debug_level, int, 0644); -MODULE_PARM_DESC(edac_debug_level, "Debug level"); -#endif |