diff options
author | Alexander Sverdlin <alexander.sverdlin@sysgo.com> | 2011-09-21 09:51:40 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-21 13:18:52 -0700 |
commit | 808bf29b9195c52239b9aaeda7c6082a0ddf07c6 (patch) | |
tree | eabb672d84cf00b13225b44fdf2482b6900b5a14 /init/main.c | |
parent | 32ef43848f283e0ef945d3c67e851c143fea3970 (diff) | |
download | linux-808bf29b9195c52239b9aaeda7c6082a0ddf07c6.tar.gz linux-808bf29b9195c52239b9aaeda7c6082a0ddf07c6.tar.bz2 linux-808bf29b9195c52239b9aaeda7c6082a0ddf07c6.zip |
init: carefully handle loglevel option on kernel cmdline.
When a malformed loglevel value (for example "${abc}") is passed on the
kernel cmdline, the loglevel itself is being set to 0.
That then suppresses all following messages, including all the errors
and crashes caused by other malformed cmdline options. This could make
debugging process quite tricky.
This patch leaves the previous value of loglevel if the new value is
incorrect and reports an error code in this case.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@sysgo.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/init/main.c b/init/main.c index 9c51ee7adf3d..2a9b88aa5e76 100644 --- a/init/main.c +++ b/init/main.c @@ -209,8 +209,19 @@ early_param("quiet", quiet_kernel); static int __init loglevel(char *str) { - get_option(&str, &console_loglevel); - return 0; + int newlevel; + + /* + * Only update loglevel value when a correct setting was passed, + * to prevent blind crashes (when loglevel being set to 0) that + * are quite hard to debug + */ + if (get_option(&str, &newlevel)) { + console_loglevel = newlevel; + return 0; + } + + return -EINVAL; } early_param("loglevel", loglevel); |