2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 18:07:40 +00:00

lldp: Fix Coverity warning about resource leak in lldp test.

Coverity reported a potential resource leak in the LLDP test code.
While this condition should never occur in practice, since the test
would crash on out-of-memory, the warning is addressed by ensuring
the cleanup function is called on error paths.

Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
This commit is contained in:
Eelco Chaudron 2025-06-05 16:51:25 +02:00
parent d283829477
commit 8fca3f99cf
2 changed files with 14 additions and 10 deletions

View File

@ -971,18 +971,21 @@ lldp_destroy_dummy(struct lldp *lldp)
cfg = lldp->lldpd;
LIST_FOR_EACH_SAFE (hw, h_entries, &cfg->g_hardware) {
ovs_list_remove(&hw->h_entries);
free(hw->h_lport.p_lastframe);
free(hw);
if (cfg) {
LIST_FOR_EACH_SAFE (hw, h_entries, &cfg->g_hardware) {
ovs_list_remove(&hw->h_entries);
free(hw->h_lport.p_lastframe);
free(hw);
}
LIST_FOR_EACH_SAFE (chassis, list, &cfg->g_chassis) {
ovs_list_remove(&chassis->list);
free(chassis);
}
free(lldp->lldpd);
}
LIST_FOR_EACH_SAFE (chassis, list, &cfg->g_chassis) {
ovs_list_remove(&chassis->list);
free(chassis);
}
free(lldp->lldpd);
free(lldp);
}

View File

@ -183,6 +183,7 @@ test_aa_send(void)
(lldp->lldpd == NULL) ||
ovs_list_is_empty(&lldp->lldpd->g_hardware)) {
printf("Error: unable to create dummy lldp instance");
lldp_destroy_dummy(lldp);
return 1;
}