From: Jarno Rajahalme Date: Fri, 14 Jun 2013 14:09:33 +0000 (+0300) Subject: ofproto: Fix use of uninitialized local variable. X-Git-Tag: sliver-openvswitch-1.10.90-3~6^2~109 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5a361239e5cdfca85e4a4be984e2826d035f9419;p=sliver-openvswitch.git ofproto: Fix use of uninitialized local variable. Also make the table id arithmetic less confusing. Signed-off-by: Jarno Rajahalme Signed-off-by: Ben Pfaff --- diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index c768d7eb6..5431fa71a 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3121,8 +3121,8 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, struct oftable *table; struct ofopgroup *group; struct rule *victim; - struct cls_rule cr; struct rule *rule; + uint8_t table_id; int error; error = check_table_id(ofproto, fm->table_id); @@ -3132,7 +3132,6 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, /* Pick table. */ if (fm->table_id == 0xff) { - uint8_t table_id; if (ofproto->ofproto_class->rule_choose_table) { error = ofproto->ofproto_class->rule_choose_table(ofproto, &fm->match, @@ -3141,16 +3140,17 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, return error; } ovs_assert(table_id < ofproto->n_tables); - table = &ofproto->tables[table_id]; } else { - table = &ofproto->tables[0]; + table_id = 0; } } else if (fm->table_id < ofproto->n_tables) { - table = &ofproto->tables[fm->table_id]; + table_id = fm->table_id; } else { return OFPERR_OFPBRC_BAD_TABLE_ID; } + table = &ofproto->tables[table_id]; + if (table->flags & OFTABLE_READONLY) { return OFPERR_OFPBRC_EPERM; } @@ -3165,7 +3165,7 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, cls_rule_init(&rule->cr, &fm->match, fm->priority); /* Serialize against pending deletion. */ - if (is_flow_deletion_pending(ofproto, &cr, table - ofproto->tables)) { + if (is_flow_deletion_pending(ofproto, &rule->cr, table_id)) { cls_rule_destroy(&rule->cr); ofproto->ofproto_class->rule_dealloc(rule); return OFPROTO_POSTPONE;