diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2019-03-19 15:14:13 +1030 |
---|---|---|
committer | Andrew Jeffery <andrew@aj.id.au> | 2019-03-19 16:41:20 +1030 |
commit | 4ef0c13275fd1a7c1b86859cfada003670bbbe20 (patch) | |
tree | f05e31a21c400b4e88a4e707074222de705869f6 | |
parent | 81059e32dfd5e8e629f30bb55f40ade65f2b0953 (diff) | |
download | phosphor-mboxbridge-4ef0c13275fd1a7c1b86859cfada003670bbbe20.tar.gz phosphor-mboxbridge-4ef0c13275fd1a7c1b86859cfada003670bbbe20.zip |
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>
-rw-r--r-- | mboxd.c | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -402,38 +402,38 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) /* 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 @@ int main(int argc, char **argv) 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 @@ finish: protocol_events_put(context, mbox_ops); protocol_events_put(context, dbus_ops); +cleanup: dbus_free(context); - backend_free(&context->backend); +cleanup_windows: + windows_free(context); +cleanup_lpc: lpc_dev_free(context); +cleanup_mbox: transport_mbox_free(context); - windows_free(context); +cleanup_protocol: protocol_free(context); +cleanup_backend: + backend_free(&context->backend); +cleanup_context: free(context); return rc; |