From 392caac04bb96ccb4005e2638fce1720e09bf211 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 30 Aug 2013 13:59:37 -0700 Subject: [PATCH] ofproto: Do not call ->rule_destruct() if ->rule_construct() failed. Found by inspection. Signed-off-by: Ben Pfaff Acked-by: Ethan Jackson --- ofproto/ofproto.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 4d33de764..03738abfc 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -199,6 +199,7 @@ static int init_ports(struct ofproto *); static void reinit_ports(struct ofproto *); /* rule. */ +static void ofproto_rule_destroy(struct rule *); static void ofproto_rule_destroy__(struct rule *); static void ofproto_rule_send_removed(struct rule *, uint8_t reason); static bool rule_is_modifiable(const struct rule *); @@ -2256,18 +2257,24 @@ update_mtu(struct ofproto *p, struct ofport *port) } static void -ofproto_rule_destroy__(struct rule *rule) +ofproto_rule_destroy(struct rule *rule) { if (rule) { rule->ofproto->ofproto_class->rule_destruct(rule); - cls_rule_destroy(&rule->cr); - free(rule->ofpacts); - ovs_mutex_destroy(&rule->timeout_mutex); - ovs_rwlock_destroy(&rule->rwlock); - rule->ofproto->ofproto_class->rule_dealloc(rule); + ofproto_rule_destroy__(rule); } } +static void +ofproto_rule_destroy__(struct rule *rule) +{ + cls_rule_destroy(&rule->cr); + free(rule->ofpacts); + ovs_mutex_destroy(&rule->timeout_mutex); + ovs_rwlock_destroy(&rule->rwlock); + rule->ofproto->ofproto_class->rule_dealloc(rule); +} + /* This function allows an ofproto implementation to destroy any rules that * remain when its ->destruct() function is called.. This function implements * steps 4.4 and 4.5 in the section titled "Rule Life Cycle" in @@ -5508,13 +5515,13 @@ ofopgroup_complete(struct ofopgroup *group) } else { ovs_rwlock_wrlock(&rule->rwlock); oftable_remove_rule(rule); - ofproto_rule_destroy__(rule); + ofproto_rule_destroy(rule); } break; case OFOPERATION_DELETE: ovs_assert(!op->error); - ofproto_rule_destroy__(rule); + ofproto_rule_destroy(rule); op->rule = NULL; break; -- 2.47.0