From: Ben Pfaff Date: Fri, 30 Aug 2013 20:59:37 +0000 (-0700) Subject: ofproto: Do not call ->rule_destruct() if ->rule_construct() failed. X-Git-Tag: sliver-openvswitch-2.0.90-1~15^2~7 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=392caac04bb96ccb4005e2638fce1720e09bf211;p=sliver-openvswitch.git ofproto: Do not call ->rule_destruct() if ->rule_construct() failed. Found by inspection. Signed-off-by: Ben Pfaff Acked-by: Ethan Jackson --- 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;