From: Jesse Gross Date: Wed, 29 Dec 2010 22:48:38 +0000 (-0800) Subject: datapath: Hold dp->mutex when calling new_vport(). X-Git-Tag: v1.1.0~546 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f072ebdd57ee86cdc86aac59b5d993cffc37e2e5;p=sliver-openvswitch.git datapath: Hold dp->mutex when calling new_vport(). On datapath creation we hold dp_mutex but not dp->mutex when creating the vport for the datapath device. However, there are lockdep checks that validate that we hold dp->mutex during the call to new_vport(). The lock isn't actually necessary in this case because no one else can access the datapath but it's good to have the lock assertions, so this holds dp->mutex while initializing the datapath. Found with lockdep. Signed-off-by: Jesse Gross Acked-by: Ben Pfaff --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 67f6730c6..d56bbf702 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -248,6 +248,7 @@ static int create_dp(int dp_idx, const char __user *devnamep) goto err_put_module; INIT_LIST_HEAD(&dp->port_list); mutex_init(&dp->mutex); + mutex_lock(&dp->mutex); dp->dp_idx = dp_idx; for (i = 0; i < DP_N_QUEUES; i++) skb_queue_head_init(&dp->queues[i]); @@ -286,6 +287,7 @@ static int create_dp(int dp_idx, const char __user *devnamep) rcu_assign_pointer(dps[dp_idx], dp); dp_sysfs_add_dp(dp); + mutex_unlock(&dp->mutex); mutex_unlock(&dp_mutex); rtnl_unlock(); @@ -296,6 +298,7 @@ err_destroy_local_port: err_destroy_table: tbl_destroy(get_table_protected(dp), NULL); err_free_dp: + mutex_unlock(&dp->mutex); kfree(dp); err_put_module: module_put(THIS_MODULE); @@ -348,7 +351,7 @@ out: return err; } -/* Called with RTNL lock and dp_mutex. */ +/* Called with RTNL lock and dp->mutex. */ static int new_vport(struct datapath *dp, struct odp_port *odp_port, int port_no) { struct vport_parms parms;