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: v2.0~64 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=5c84ce6741382877e43798579b535d14ddc9808c 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 b7f265e53..a8634aa3d 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 *); @@ -2247,18 +2248,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 @@ -5028,13 +5035,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;