[ovs-dev] [PATCH 1/4] ofproto: Fix memory leak in ofproto_rule_delete().

Jarno Rajahalme jrajahalme at nicira.com
Tue Jun 9 22:25:07 UTC 2015


Commit () fixed the memory leak when a rule is deleted, but failed to
do the same when all rules in a bridge are deleted just before the
bridge itself is deleted.

This patch adds the necessary unref to ofproto_rule_delete().

Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
 ofproto/ofproto.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 0a1d032..029ff37 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1443,6 +1443,7 @@ ofproto_rule_delete(struct ofproto *ofproto, struct rule *rule)
     ovs_mutex_lock(&ofproto_mutex);
     oftable_remove_rule(rule);
     ofproto->ofproto_class->rule_delete(rule);
+    ofproto_rule_unref(rule);
     ovs_mutex_unlock(&ofproto_mutex);
 }
 
@@ -4842,7 +4843,9 @@ delete_flows__(const struct rule_collection *rules,
             if (next_table == rule->table_id) {
                 classifier_defer(cls);
             }
-            classifier_remove(cls, &rule->cr);
+            if (!classifier_remove(cls, &rule->cr)) {
+                OVS_NOT_REACHED();
+            }
             if (next_table != rule->table_id) {
                 classifier_publish(cls);
             }
@@ -7364,6 +7367,8 @@ oftable_remove_rule(struct rule *rule)
 
     if (classifier_remove(cls, &rule->cr)) {
         ofproto_rule_remove__(rule->ofproto, rule);
+    } else {
+        OVS_NOT_REACHED();
     }
 }
 
-- 
1.7.10.4




More information about the dev mailing list