From: Jesse Gross Date: Thu, 29 Jul 2010 22:59:31 +0000 (-0700) Subject: vport: Make dp_port->vport always valid. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc98976af50fec5643a372aa9c7a4c4e565e939e;p=openvswitch vport: Make dp_port->vport always valid. When we detached a vport we would assign NULL to dp_port->vport before calling synchronize_rcu(). However, since vports have a longer lifetime than dp_ports there were no checks before dereferencing dp_port->vport. This changes the behavior to match the assumption by not assigning NULL during detach. This avoids a potential NULL pointer dereference in do_output() among other places. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 73f73480..d0db5507 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -377,6 +377,7 @@ static int new_dp_port(struct datapath *dp, struct odp_port *odp_port, int port_ p->port_no = port_no; p->dp = dp; + p->vport = vport; atomic_set(&p->sflow_pool, 0); err = vport_attach(vport, p); diff --git a/datapath/vport.c b/datapath/vport.c index 712c26e5..24385901 100644 --- a/datapath/vport.c +++ b/datapath/vport.c @@ -798,9 +798,6 @@ int vport_attach(struct vport *vport, struct dp_port *dp_port) { ASSERT_RTNL(); - if (dp_port->vport) - return -EBUSY; - if (vport_get_dp_port(vport)) return -EBUSY; @@ -812,7 +809,6 @@ int vport_attach(struct vport *vport, struct dp_port *dp_port) return err; } - dp_port->vport = vport; rcu_assign_pointer(vport->dp_port, dp_port); return 0; @@ -836,7 +832,6 @@ int vport_detach(struct vport *vport) if (!dp_port) return -EINVAL; - dp_port->vport = NULL; rcu_assign_pointer(vport->dp_port, NULL); if (vport->ops->detach)