spi/flashconsole: Fix internal buffer overflow
Once the console's FMAP region is full, we stop clearing the line buffer and `line_offset` is not reset anymore. Hence, sanity check `line_offset` everytime before writing to the buffer. The issue resulted in boot hangs and potentially a brick if the log was very verbose. Change-Id: I36e9037d7baf8c1ed8b2d0c120bfffa58c089c95 Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/48074 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
20426858c5
commit
361a5c0952
|
@ -75,6 +75,7 @@ void flashconsole_tx_byte(unsigned char c)
|
||||||
|
|
||||||
size_t region_size = region_device_sz(rdev_ptr);
|
size_t region_size = region_device_sz(rdev_ptr);
|
||||||
|
|
||||||
|
if (line_offset < LINE_BUFFER_SIZE)
|
||||||
line_buffer[line_offset++] = c;
|
line_buffer[line_offset++] = c;
|
||||||
|
|
||||||
if (line_offset >= LINE_BUFFER_SIZE ||
|
if (line_offset >= LINE_BUFFER_SIZE ||
|
||||||
|
|
Loading…
Reference in New Issue