Re: [PATCH] init: Carefuly handle loglevel option passed to kernel cmdline.

From: Linus Torvalds
Date: Tue Sep 20 2011 - 10:56:36 EST


On Tue, Sep 20, 2011 at 6:45 AM, Alexander Sverdlin <asv@xxxxxxxxx> wrote:
>
> Carefuly handle loglevel option passed to kernel cmdline.

Ugh. I dislike how you misuse the error numbers - it *happens* to
work, but we return negative error numbers, not positive ones in the
kernel.

Also, doing an if/else when one arm does a return just looks overly complicated.

Does this (whitespace-damaged) patch work for you?

Linus

---
init/main.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/init/main.c b/init/main.c
index 9c51ee7adf3d..5827722ec491 100644
--- a/init/main.c
+++ b/init/main.c
@@ -209,7 +209,11 @@ early_param("quiet", quiet_kernel);

static int __init loglevel(char *str)
{
- get_option(&str, &console_loglevel);
+ int loglevel;
+
+ if (!get_option(&str, &loglevel))
+ return -EINVAL;
+ console_loglevel = loglevel;
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/