The route_table_parse() can allocate data related to the nexthop
list. Those data need to be freed when we are done with the message.
Make sure we call route_data_destroy() when we are done with the
change.

Fixes: 673d90f1173f ("controller: Watch for route changes.")
Signed-off-by: Ales Musil <[email protected]>
---
 controller/route-table-notify.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/controller/route-table-notify.c b/controller/route-table-notify.c
index 1fa182ea5..9fa2e0ea6 100644
--- a/controller/route-table-notify.c
+++ b/controller/route-table-notify.c
@@ -134,19 +134,22 @@ find_watch_entry(uint32_t table_id)
 static void
 route_table_change(const void *change_, void *aux OVS_UNUSED)
 {
-    /* We currently track whether at least one recent route table change
-     * was detected.  If that's the case already there's no need to
-     * continue. */
-    if (any_route_table_changed) {
+    if (!change_) {
         return;
     }
 
-    const struct route_table_msg *change = change_;
-    if (change && change->rd.rtm_protocol != RTPROT_OVN) {
+    /* We currently track whether at least one recent route table change
+     * was detected.  If that's the case already there's no need to
+     * continue. */
+    struct route_table_msg *change =
+        CONST_CAST(struct route_table_msg *, change_);
+    if (!any_route_table_changed && change->rd.rtm_protocol != RTPROT_OVN) {
         if (find_watch_entry(change->rd.rta_table_id)) {
             any_route_table_changed = true;
         }
     }
+
+    route_data_destroy(&change->rd);
 }
 
 static void
-- 
2.53.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to