[ovs-dev] [PATCH 10/12] datapath: Validate access to DP array.

Jesse Gross jesse at nicira.com
Sun Dec 12 20:53:05 UTC 2010


When access the array of DPs, we need to hold either rcu_read_lock
or dp_mutex.  This enables lockdep to validate those conditions.

Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/datapath.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 8096b2f..db68057 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -77,7 +77,8 @@ struct datapath *get_dp(int dp_idx)
 {
 	if (dp_idx < 0 || dp_idx >= ODP_MAX)
 		return NULL;
-	return rcu_dereference(dps[dp_idx]);
+	return rcu_dereference_check(dps[dp_idx], rcu_read_lock_held() ||
+					 lockdep_is_held(&dp_mutex));
 }
 EXPORT_SYMBOL_GPL(get_dp);
 
-- 
1.7.1





More information about the dev mailing list