From eb3ccf114ad0780225d4e30315b7aa2dab9e200c Mon Sep 17 00:00:00 2001
From: Jesse Gross <jesse@nicira.com>
Date: Wed, 8 Dec 2010 11:07:56 -0800
Subject: [PATCH] datapath: Validate access to DP array.

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@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
---
 datapath/datapath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index b44c96792..8960a060e 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);
 
-- 
2.47.0