Message ID | b443efc54c5127479fc0df937fbc1f143234eed2.1749133911.git.echaudro@redhat.com |
---|---|
State | Accepted |
Commit | 8fca3f99cf199a73e8ec1e4646b51e04fe011a70 |
Delegated to: | aaron conole |
Headers | show |
Series | Various Coverity fixes. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
Eelco Chaudron via dev <ovs-dev@openvswitch.org> writes: > 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. > > Signed-off-by: Eelco Chaudron <echaudro@redhat.com> > --- Acked-by: Aaron Conole <aconole@redhat.com>
On 5 Jun 2025, at 18:38, Aaron Conole wrote: > Eelco Chaudron via dev <ovs-dev@openvswitch.org> writes: > >> 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. >> >> Signed-off-by: Eelco Chaudron <echaudro@redhat.com> >> --- > > Acked-by: Aaron Conole <aconole@redhat.com> Thanks for the review Aaron! Applied to main. //Eelco
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c index 2d13e971e..863a1b644 100644 --- a/lib/ovs-lldp.c +++ b/lib/ovs-lldp.c @@ -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); + LIST_FOR_EACH_SAFE (chassis, list, &cfg->g_chassis) { + ovs_list_remove(&chassis->list); + free(chassis); + } + + free(lldp->lldpd); } - free(lldp->lldpd); free(lldp); } diff --git a/tests/test-aa.c b/tests/test-aa.c index 1c0fb2926..ba21d5908 100644 --- a/tests/test-aa.c +++ b/tests/test-aa.c @@ -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; }
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. Signed-off-by: Eelco Chaudron <echaudro@redhat.com> --- lib/ovs-lldp.c | 21 ++++++++++++--------- tests/test-aa.c | 1 + 2 files changed, 13 insertions(+), 9 deletions(-)