mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 22:07:43 +00:00
ldpd: fix segfault after failed initialization
When ldpd fails to start for some reason, like failing to create a pid file, the child processes call their shutdown functions without being completely initialized. This patch adds some protections to prevent a segmentation fault on such circumstances. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
e75f810c2f
commit
b3121cd7d1
@ -216,8 +216,10 @@ static void
|
||||
lde_shutdown(void)
|
||||
{
|
||||
/* close pipes */
|
||||
if (iev_ldpe) {
|
||||
msgbuf_clear(&iev_ldpe->ibuf.w);
|
||||
close(iev_ldpe->ibuf.fd);
|
||||
}
|
||||
msgbuf_clear(&iev_main->ibuf.w);
|
||||
close(iev_main->ibuf.fd);
|
||||
msgbuf_clear(&iev_main_sync->ibuf.w);
|
||||
@ -229,6 +231,7 @@ lde_shutdown(void)
|
||||
|
||||
config_clear(ldeconf);
|
||||
|
||||
if (iev_ldpe)
|
||||
free(iev_ldpe);
|
||||
free(iev_main);
|
||||
free(iev_main_sync);
|
||||
|
@ -196,9 +196,11 @@ ldpe_shutdown(void)
|
||||
struct adj *adj;
|
||||
|
||||
/* close pipes */
|
||||
if (iev_lde) {
|
||||
msgbuf_write(&iev_lde->ibuf.w);
|
||||
msgbuf_clear(&iev_lde->ibuf.w);
|
||||
close(iev_lde->ibuf.fd);
|
||||
}
|
||||
msgbuf_write(&iev_main->ibuf.w);
|
||||
msgbuf_clear(&iev_main->ibuf.w);
|
||||
close(iev_main->ibuf.fd);
|
||||
@ -226,6 +228,7 @@ ldpe_shutdown(void)
|
||||
adj_del(adj, S_SHUTDOWN);
|
||||
|
||||
/* clean up */
|
||||
if (iev_lde)
|
||||
free(iev_lde);
|
||||
free(iev_main);
|
||||
free(iev_main_sync);
|
||||
|
Loading…
Reference in New Issue
Block a user