From: Petr Mladek Date: Tue, 12 Dec 2017 12:49:39 +0100 Subject: libconsole: Correctly ignore early consoles Git-commit: 08b7314b53524040a16ce2a7f95a73304c55db30 References: bsc#1071568 Upstream: merged There might be consoles without tty binding. These do not have defined major and minor numbers in the /proc/consoles list. For example, it might look like: $> cat /proc/consoles pl11 -W- (E Bp ) ttyAMA0 -W- (EC p a) 204:64 Let's just ignore them. Signed-off-by: Petr Mladek --- libconsole/console.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libconsole/console.c b/libconsole/console.c index 47e95a4b9046..c4396b1f9b5e 100644 --- a/libconsole/console.c +++ b/libconsole/console.c @@ -609,6 +609,7 @@ void getconsoles(struct console **cons, int io) char fbuf[16], dev[64]; char *tty = NULL; FILE *fc; + int items; if (!cons) error("error: console pointer empty"); @@ -621,11 +622,16 @@ void getconsoles(struct console **cons, int io) goto err; } - while ((fscanf(fc, "%*s %*s (%[^)]) %[0-9:]", &fbuf[0], &dev[0]) == 2)) { + while ((items = fscanf(fc, "%*s %*s (%[^)]) %[0-9:]", &fbuf[0], &dev[0])) + != EOF) { char *tmp; int flags, n, maj, min; int ret; + /* Ignore consoles without tty binding. */ + if (items != 2) + continue; + if (!strchr(fbuf, 'E')) continue; -- 2.13.6