summaryrefslogtreecommitdiff
path: root/lib/dpif-netdev.c
diff options
context:
space:
mode:
authorAlex Wang <alexw@nicira.com>2014-11-07 17:11:07 -0800
committerAlex Wang <alexw@nicira.com>2014-11-12 15:59:11 -0800
commitf7d636527b72231822ed3e25fe74edbc1a5ec41f (patch)
treee2727bb90a000e840b075b91e3b94cf2e7c4df24 /lib/dpif-netdev.c
parent886af6eaea556e53bf1d32025849202c3334f41f (diff)
downloadopenvswitch-f7d636527b72231822ed3e25fe74edbc1a5ec41f.tar.gz
dpif-netdev: Move 'struct dp_netdev_port' initialization before use.
There is a portion of the 'struct dp_netdev_port' initialization that is placed after the reload of pmd threads. This means in theory, there could be a race where pmd threads access half- initialized struct. Although such race has not been seen, it makes sense to fully initialize the struct before use. Found by code inspection. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
Diffstat (limited to 'lib/dpif-netdev.c')
-rw-r--r--lib/dpif-netdev.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 000995505..c134c4372 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -862,13 +862,13 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
}
port->sf = sf;
+ ovs_refcount_init(&port->ref_cnt);
+ cmap_insert(&dp->ports, &port->node, hash_port_no(port_no));
+
if (netdev_is_pmd(netdev)) {
dp_netdev_set_pmds_on_numa(dp, netdev_get_numa_id(netdev));
dp_netdev_reload_pmds(dp);
}
- ovs_refcount_init(&port->ref_cnt);
-
- cmap_insert(&dp->ports, &port->node, hash_port_no(port_no));
seq_change(dp->port_seq);
return 0;