ofproto: Fix memory leak in ofproto_rule_delete().
authorJarno Rajahalme <jrajahalme@nicira.com>
Tue, 9 Jun 2015 22:24:33 +0000 (15:24 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Tue, 9 Jun 2015 22:24:33 +0000 (15:24 -0700)
Commit 401aa90e33be (ofproto: Fix memory leak in flow deletion.) 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@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index 0a1d032..029ff37 100644 (file)
@@ -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();
     }
 }
 \f