console-server: Avoid SEGV on on failure to load configuration

On a system without a file at the default configuration path we hit
a SEGV:

```
$ ./build/obmc-console-server -i test $(realpath pts)
obmc-console-server: Can't open configuration file etc/obmc-console.conf: No such file or directory
../config.c:56:48: runtime error: member access within null pointer of type 'struct config'
AddressSanitizer:DEADLYSIGNAL
=================================================================
==693793==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x55be18aa0d76 bp 0x7ffe1f8a5640 sp 0x7ffe1f8a53a0 T0)
==693793==The signal is caused by a READ memory access.
==693793==Hint: address points to the zero page.
    #0 0x55be18aa0d76 in config_get_value ../config.c:56
    #1 0x55be18a9e10e in main ../console-server.c:985
    #2 0x7f80bd046249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0x7f80bd046304 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0x55be18aa0be0 in _start (/home/andrew/src/openbmc.org/openbmc/obmc-console/build/obmc-console-server+0x25be0)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../config.c:56 in config_get_value
==693793==ABORTING
```

Rework the cleanup sequence in main() to avoid the problem.

Change-Id: I6cbea10889d65666d660ee198c4ad6f6935fea85
Fixes: 1e04f449b7f0 ("use iniparser dependency for config file parsing")
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/console-server.c b/console-server.c
index 7bddc4c..bd94fa6 100644
--- a/console-server.c
+++ b/console-server.c
@@ -977,11 +977,20 @@
 	}
 
 	config = config_init(config_filename);
+	if (!config) {
+		return EXIT_FAILURE;
+	}
 
 	console = malloc(sizeof(struct console));
+	if (!console) {
+		rc = -1;
+		goto out_config_fini;
+	}
+
 	memset(console, 0, sizeof(*console));
 	console->pollfds =
 		calloc(MAX_INTERNAL_POLLFD, sizeof(*console->pollfds));
+
 	buffer_size_str = config_get_value(config, "ringbuffer-size");
 	if (buffer_size_str) {
 		rc = config_parse_bytesize(buffer_size_str, &buffer_size);
@@ -993,7 +1002,7 @@
 	console->rb = ringbuffer_init(buffer_size);
 	if (!console->rb) {
 		rc = -1;
-		goto out_config_fini;
+		goto out_console_fini;
 	}
 
 	if (set_socket_info(console, config, console_id)) {
@@ -1025,12 +1034,13 @@
 out_ringbuffer_fini:
 	ringbuffer_fini(console->rb);
 
-out_config_fini:
-	config_fini(config);
-
+out_console_fini:
 	free(console->pollers);
 	free(console->pollfds);
 	free(console);
 
+out_config_fini:
+	config_fini(config);
+
 	return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }