Skip to content

Commit

Permalink
Merge pull request #18044 from FRRouting/mergify/bp/stable/10.2/pr-18038
Browse files Browse the repository at this point in the history
pimd: fix memory leak and assign allocation type (backport #18038)
  • Loading branch information
Jafaral authored Feb 6, 2025
2 parents 52a0d16 + c0e3a5c commit fc4e136
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions pimd/pim_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DEFINE_MTYPE(PIMD, PIM_STATIC_ROUTE, "PIM Static Route");
DEFINE_MTYPE(PIMD, PIM_RP, "PIM RP info");
DEFINE_MTYPE(PIMD, PIM_FILTER_NAME, "PIM RP filter info");
DEFINE_MTYPE(PIMD, PIM_MSDP_PEER, "PIM MSDP peer");
DEFINE_MTYPE(PIMD, PIM_MSDP_FILTER_NAME, "PIM MSDP peer filter name");
DEFINE_MTYPE(PIMD, PIM_MSDP_MG_NAME, "PIM MSDP mesh-group name");
DEFINE_MTYPE(PIMD, PIM_MSDP_AUTH_KEY, "PIM MSDP authentication key");
DEFINE_MTYPE(PIMD, PIM_MSDP_SA, "PIM MSDP source-active cache");
Expand Down
1 change: 1 addition & 0 deletions pimd/pim_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ DECLARE_MTYPE(PIM_STATIC_ROUTE);
DECLARE_MTYPE(PIM_RP);
DECLARE_MTYPE(PIM_FILTER_NAME);
DECLARE_MTYPE(PIM_MSDP_PEER);
DECLARE_MTYPE(PIM_MSDP_FILTER_NAME);
DECLARE_MTYPE(PIM_MSDP_MG_NAME);
DECLARE_MTYPE(PIM_MSDP_SA);
DECLARE_MTYPE(PIM_MSDP_MG);
Expand Down
2 changes: 2 additions & 0 deletions pimd/pim_msdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,8 @@ static void pim_msdp_peer_free(struct pim_msdp_peer *mp)
if (mp->auth_listen_sock != -1)
close(mp->auth_listen_sock);

XFREE(MTYPE_PIM_MSDP_FILTER_NAME, mp->acl_in);
XFREE(MTYPE_PIM_MSDP_FILTER_NAME, mp->acl_out);
XFREE(MTYPE_PIM_MSDP_MG_NAME, mp->mesh_group_name);

mp->pim = NULL;
Expand Down
12 changes: 6 additions & 6 deletions pimd/pim_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,8 @@ int pim_msdp_peer_sa_filter_in_modify(struct nb_cb_modify_args *args)
break;
case NB_EV_APPLY:
mp = nb_running_get_entry(args->dnode, NULL, true);
XFREE(MTYPE_TMP, mp->acl_in);
mp->acl_in = XSTRDUP(MTYPE_TMP,
XFREE(MTYPE_PIM_MSDP_FILTER_NAME, mp->acl_in);
mp->acl_in = XSTRDUP(MTYPE_PIM_MSDP_FILTER_NAME,
yang_dnode_get_string(args->dnode, NULL));
break;
}
Expand All @@ -1408,7 +1408,7 @@ int pim_msdp_peer_sa_filter_in_destroy(struct nb_cb_destroy_args *args)
break;
case NB_EV_APPLY:
mp = nb_running_get_entry(args->dnode, NULL, true);
XFREE(MTYPE_TMP, mp->acl_in);
XFREE(MTYPE_PIM_MSDP_FILTER_NAME, mp->acl_in);
break;
}

Expand All @@ -1431,8 +1431,8 @@ int pim_msdp_peer_sa_filter_out_modify(struct nb_cb_modify_args *args)
break;
case NB_EV_APPLY:
mp = nb_running_get_entry(args->dnode, NULL, true);
XFREE(MTYPE_TMP, mp->acl_out);
mp->acl_out = XSTRDUP(MTYPE_TMP,
XFREE(MTYPE_PIM_MSDP_FILTER_NAME, mp->acl_out);
mp->acl_out = XSTRDUP(MTYPE_PIM_MSDP_FILTER_NAME,
yang_dnode_get_string(args->dnode, NULL));
break;
}
Expand All @@ -1452,7 +1452,7 @@ int pim_msdp_peer_sa_filter_out_destroy(struct nb_cb_destroy_args *args)
break;
case NB_EV_APPLY:
mp = nb_running_get_entry(args->dnode, NULL, true);
XFREE(MTYPE_TMP, mp->acl_out);
XFREE(MTYPE_PIM_MSDP_FILTER_NAME, mp->acl_out);
break;
}

Expand Down

0 comments on commit fc4e136

Please sign in to comment.