Skip to content

Commit

Permalink
main: fix segfault when running br --help
Browse files Browse the repository at this point in the history
Do not try to run modules_fini() if modules_init() wasn't called...

Signed-off-by: Robin Jarry <[email protected]>
  • Loading branch information
rjarry committed Mar 23, 2024
1 parent 9547d42 commit 1cceefe
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,33 +330,34 @@ int main(int argc, char **argv) {
goto end;

if (dpdk_init(&br) < 0)
goto end;
goto dpdk_stop;

modules_init();

if ((ev_base = event_base_new()) == NULL) {
LOG(ERR, "event_base_new: %s", strerror(errno));
goto end;
goto shutdown;
}

if (listen_api_socket() < 0)
goto end;
goto shutdown;

if (register_signals(ev_base) < 0)
goto end;
goto shutdown;

// run until signal or fatal error
if (event_base_dispatch(ev_base) == 0)
ret = EXIT_SUCCESS;

end:
shutdown:
unregister_signals();
if (ev_base)
event_base_free(ev_base);
unlink(br.api_sock_path);
libevent_global_shutdown();
modules_fini();
dpdk_stop:
dpdk_fini();

end:
return ret;
}

0 comments on commit 1cceefe

Please sign in to comment.