Skip to content

Commit

Permalink
printk: handle blank console arguments passed in.
Browse files Browse the repository at this point in the history
If uboot passes a blank string to console_setup then it results in
a trashed memory. Ultimately, the kernel crashes during freeing up
the memory.

This fix checks if there is a blank parameter being
passed to console_setup from uboot. In case it detects that
the console parameter is blank then it doesn't setup the serial
device and it gracefully exits.

Link: https://lore.kernel.org/r/20200522065306.83-1-shreyas.joshi@biamp.com
Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com>
Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
[pmladek@suse.com: Better format the commit message and code, remove unnecessary brackets.]
Signed-off-by: Petr Mladek <pmladek@suse.com>
  • Loading branch information
Shreyas Joshi authored and pmladek committed May 22, 2020
1 parent 8ece3b3 commit 48021f9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,9 @@ static int __init console_setup(char *str)
char *s, *options, *brl_options = NULL;
int idx;

if (str[0] == 0)
return 1;

if (_braille_console_setup(&str, &brl_options))
return 1;

Expand Down

0 comments on commit 48021f9

Please sign in to comment.