libpayload: video: Check for 'console' pointer before dereferencing it
Seems that the 'if (cursor_enabled)' check in video_console_fixup_cursor() that was removed in commit1f880bca0really meant to check for 'if (console)'. Looks like the whole video console driver is built extra robust to not fail no matter how screwed up the console is, so let's add this missing check here as well. Also fixed up a few other missing 'if (!console)' checks while I'm at it. However, what payloads should really be doing is check the return value of video_(console_)init() and not call the other video functions if that failed. This also adapts video_console_init() to correctly pass through the return value for that purpose (something that seems to have been overlooked in thedd9e4e58refactoring). BUG=chrome-os-partner:28494 TEST=None. I don't know what Dave did to trigger this in the first place, but it's pretty straight-forward. Change-Id: I1b9f09d49dc70dacf20621b19e081c754d4814f7 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200688 Reviewed-by: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
parent
7a09cc553c
commit
3f01d1dc09
1 changed files with 15 additions and 13 deletions
|
|
@ -73,6 +73,9 @@ void video_get_rows_cols(unsigned int *rows, unsigned int *cols)
|
|||
|
||||
static void video_console_fixup_cursor(void)
|
||||
{
|
||||
if (!console)
|
||||
return;
|
||||
|
||||
if (cursorx < 0)
|
||||
cursorx = 0;
|
||||
|
||||
|
|
@ -89,7 +92,7 @@ static void video_console_fixup_cursor(void)
|
|||
cursory--;
|
||||
}
|
||||
|
||||
if (console && console->set_cursor)
|
||||
if (console->set_cursor)
|
||||
console->set_cursor(cursorx, cursory);
|
||||
}
|
||||
|
||||
|
|
@ -119,6 +122,9 @@ void video_console_putc(u8 row, u8 col, unsigned int ch)
|
|||
|
||||
void video_console_putchar(unsigned int ch)
|
||||
{
|
||||
if (!console)
|
||||
return;
|
||||
|
||||
/* replace black-on-black with light-gray-on-black.
|
||||
* do it here, instead of in libc/console.c
|
||||
*/
|
||||
|
|
@ -145,16 +151,11 @@ void video_console_putchar(unsigned int ch)
|
|||
break;
|
||||
|
||||
case '\t':
|
||||
while(cursorx % 8 && cursorx < console->columns) {
|
||||
if (console)
|
||||
console->putc(cursory, cursorx, (ch & 0xFF00) | ' ');
|
||||
|
||||
cursorx++;
|
||||
}
|
||||
while(cursorx % 8 && cursorx < console->columns)
|
||||
console->putc(cursory, cursorx++, (ch & 0xFF00) | ' ');
|
||||
break;
|
||||
default:
|
||||
if (console)
|
||||
console->putc(cursory, cursorx++, ch);
|
||||
console->putc(cursory, cursorx++, ch);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +168,7 @@ void video_console_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en
|
|||
*y=0;
|
||||
*en=0;
|
||||
|
||||
if (console->get_cursor)
|
||||
if (console && console->get_cursor)
|
||||
console->get_cursor(x, y, en);
|
||||
|
||||
*x = cursorx;
|
||||
|
|
@ -214,9 +215,10 @@ int video_init(void)
|
|||
|
||||
int video_console_init(void)
|
||||
{
|
||||
video_init();
|
||||
if (console)
|
||||
console_add_output_driver(&cons);
|
||||
int ret = video_init();
|
||||
if (ret)
|
||||
return ret;
|
||||
console_add_output_driver(&cons);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue