mboxd: Tidy up failure paths on daemon startup
Don't try to cleanup objects we haven't initialised.
Change-Id: I218ab785af36bc3a1d3085c9dcd575e812402433
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/mboxd.c b/mboxd.c
index 70580de..2026023 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -402,38 +402,38 @@
rc = init_signals(context, &set);
if (rc) {
- goto finish;
+ goto cleanup_context;
}
rc = mboxd_backend_init(context);
if (rc) {
- goto finish;
+ goto cleanup_context;
}
rc = protocol_init(context);
if (rc) {
- goto finish;
+ goto cleanup_backend;
}
rc = transport_mbox_init(context, &mbox_ops);
if (rc) {
- goto finish;
+ goto cleanup_protocol;
}
rc = lpc_dev_init(context);
if (rc) {
- goto finish;
+ goto cleanup_mbox;
}
/* We've found the reserved memory region -> we can assign to windows */
rc = windows_init(context);
if (rc) {
- goto finish;
+ goto cleanup_lpc;
}
rc = dbus_init(context, &dbus_ops);
if (rc) {
- goto finish;
+ goto cleanup_windows;
}
/* Set the LPC bus mapping */
@@ -446,12 +446,12 @@
/* Alert on all supported transports */
rc = protocol_events_put(context, mbox_ops);
if (rc) {
- goto finish;
+ goto cleanup;
}
rc = protocol_events_put(context, dbus_ops);
if (rc) {
- goto finish;
+ goto cleanup;
}
MSG_INFO("Entering Polling Loop\n");
@@ -459,7 +459,6 @@
MSG_INFO("Exiting Poll Loop: %d\n", rc);
-finish:
MSG_INFO("Daemon Exiting...\n");
context->bmc_events &= ~BMC_EVENT_DAEMON_READY;
context->bmc_events |= BMC_EVENT_PROTOCOL_RESET;
@@ -468,12 +467,19 @@
protocol_events_put(context, mbox_ops);
protocol_events_put(context, dbus_ops);
+cleanup:
dbus_free(context);
- backend_free(&context->backend);
- lpc_dev_free(context);
- transport_mbox_free(context);
+cleanup_windows:
windows_free(context);
+cleanup_lpc:
+ lpc_dev_free(context);
+cleanup_mbox:
+ transport_mbox_free(context);
+cleanup_protocol:
protocol_free(context);
+cleanup_backend:
+ backend_free(&context->backend);
+cleanup_context:
free(context);
return rc;