]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
EDAC: Boundary-check edac_debug_level
authorBorislav Petkov <borislav.petkov@amd.com>
Mon, 10 Sep 2012 14:50:54 +0000 (16:50 +0200)
committerBorislav Petkov <bp@alien8.de>
Wed, 28 Nov 2012 10:23:32 +0000 (11:23 +0100)
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>
drivers/edac/Kconfig
drivers/edac/edac_module.c

index 409b92b8d346087b4ec292bda8790d03cc764224..bb82d6be793cdc3a61164008f5d73bdb4356e077 100644 (file)
@@ -42,10 +42,10 @@ config EDAC_LEGACY_SYSFS
 config EDAC_DEBUG
        bool "Debugging"
        help
-         This turns on debugging information for the entire EDAC
-         sub-system. You can insert module with "debug_level=x", current
-         there're four debug levels (x=0,1,2,3 from low to high).
-         Usually you should select 'N'.
+         This turns on debugging information for the entire EDAC subsystem.
+         You do so by inserting edac_module with "edac_debug_level=x." Valid
+         levels are 0-4 (from low to high) and by default it is set to 2.
+         Usually you should select 'N' here.
 
 config EDAC_DECODE_MCE
        tristate "Decode MCEs in human-readable form (only on AMD for now)"
index 58a28d838f37bfef26450bacdf11c8a338f6dcc7..12c951a2c33d5c8bac6d80bf6f0221467278940e 100644 (file)
 #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