diff mbox series

[ovs-dev,1/2] vif-plug: Fix small memory leak when exiting.

Message ID 20240903120120.1864392-2-xsimonar@redhat.com
State New
Headers show
Series Vif-plug transaction errors and memory leak. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Xavier Simonart Sept. 3, 2024, 12:01 p.m. UTC
A small memory leak was possible when exiting ovn-controller while an ovsdb
transaction was pending.

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
---
 controller/ovn-controller.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index c48667887..9101dfa8d 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -5908,7 +5908,22 @@  loop_done:
             }
 
             ovsdb_idl_loop_commit_and_wait(&ovnsb_idl_loop);
-            ovsdb_idl_loop_commit_and_wait(&ovs_idl_loop);
+            int ovs_txn_status = ovsdb_idl_loop_commit_and_wait(&ovs_idl_loop);
+            if (!ovs_txn_status) {
+                /* The transaction failed. */
+                vif_plug_clear_deleted(
+                        &vif_plug_deleted_iface_ids);
+                vif_plug_clear_changed(
+                        &vif_plug_changed_iface_ids);
+            } else if (ovs_txn_status == 1) {
+                /* The transaction committed successfully
+                 * (or it did not change anything in the database). */
+                vif_plug_finish_deleted(
+                        &vif_plug_deleted_iface_ids);
+                vif_plug_finish_changed(
+                        &vif_plug_changed_iface_ids);
+            }
+
             poll_block();
         }
     }