console-server: tty_find_device(): Assign rc on error
Avoid invoking open(2) with console->tty_dev as NULL:
```
[12/34] Compiling C object obmc-console-server.p/console-server.c.o
../../../console-server.c:263:20: warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker]
console->tty_fd = open(console->tty_dev, O_RDWR);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Iafb2e6ac790f66f71d591a68d1b918117074fd77
diff --git a/console-server.c b/console-server.c
index 17a923a..3c71904 100644
--- a/console-server.c
+++ b/console-server.c
@@ -124,12 +124,14 @@
tty_path_input_real = realpath(tty_path_input, NULL);
if (!tty_path_input_real) {
warn("Can't find realpath for /dev/%s", console->tty_kname);
+ rc = -1;
goto out_free;
}
tty_kname_real = basename(tty_path_input_real);
if (!tty_kname_real) {
warn("Can't find real name for /dev/%s", console->tty_kname);
+ rc = -1;
goto out_free;
}
@@ -141,6 +143,7 @@
tty_device_tty_dir = realpath(tty_class_device_link, NULL);
if (!tty_device_tty_dir) {
warn("Can't query sysfs for device %s", tty_kname_real);
+ rc = -1;
goto out_free;
}