datapath: Validate access to DP array.
authorJesse Gross <jesse@nicira.com>
Wed, 8 Dec 2010 19:07:56 +0000 (11:07 -0800)
committerJesse Gross <jesse@nicira.com>
Mon, 13 Dec 2010 21:43:36 +0000 (13:43 -0800)
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

index b44c967..8960a06 100644 (file)
@@ -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);