aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2011-11-21 05:23:50 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-11-21 16:22:10 -0500
commit30be52e44fd4276d768efffb55d424fb682e6505 (patch)
tree15ccf1db03149f280c23056922b33c520d101279
parent11a2a357a9d8e058db032883ffd535bf4ad6a899 (diff)
mac80211: fix RCU warnings in mesh
Sparse RCU checking reports two warnings in the mesh path table code. These are due to questionable uses of rcu_dereference. To fix the first one, get rid of mesh_gate_add() and just make mesh_path_add_gate() do the correct deref. To fix the second one, simply remove rcu_dereference() in mesh_gate_del() -- it already gets a proper pointer as indicated by the prototype (no __rcu annotation) and confirmed by the code. Cc: Javier Cardona <javier@cozybit.com> Cc: Thomas Pedersen <thomas@cozybit.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/mac80211/mesh_pathtbl.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 4fc23d1b9c3a..7bd2a76aef0e 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -69,8 +69,6 @@ static inline struct mesh_table *resize_dereference_mpp_paths(void)
69 lockdep_is_held(&pathtbl_resize_lock)); 69 lockdep_is_held(&pathtbl_resize_lock));
70} 70}
71 71
72static int mesh_gate_add(struct mesh_table *tbl, struct mesh_path *mpath);
73
74/* 72/*
75 * CAREFUL -- "tbl" must not be an expression, 73 * CAREFUL -- "tbl" must not be an expression,
76 * in particular not an rcu_dereference(), since 74 * in particular not an rcu_dereference(), since
@@ -420,21 +418,18 @@ static void mesh_gate_node_reclaim(struct rcu_head *rp)
420} 418}
421 419
422/** 420/**
423 * mesh_gate_add - mark mpath as path to a mesh gate and add to known_gates 421 * mesh_path_add_gate - add the given mpath to a mesh gate to our path table
424 * @mesh_tbl: table which contains known_gates list 422 * @mpath: gate path to add to table
425 * @mpath: mpath to known mesh gate
426 *
427 * Returns: 0 on success
428 *
429 */ 423 */
430static int mesh_gate_add(struct mesh_table *tbl, struct mesh_path *mpath) 424int mesh_path_add_gate(struct mesh_path *mpath)
431{ 425{
426 struct mesh_table *tbl;
432 struct mpath_node *gate, *new_gate; 427 struct mpath_node *gate, *new_gate;
433 struct hlist_node *n; 428 struct hlist_node *n;
434 int err; 429 int err;
435 430
436 rcu_read_lock(); 431 rcu_read_lock();
437 tbl = rcu_dereference(tbl); 432 tbl = rcu_dereference(mesh_paths);
438 433
439 hlist_for_each_entry_rcu(gate, n, tbl->known_gates, list) 434 hlist_for_each_entry_rcu(gate, n, tbl->known_gates, list)
440 if (gate->mpath == mpath) { 435 if (gate->mpath == mpath) {
@@ -478,8 +473,6 @@ static int mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
478 struct mpath_node *gate; 473 struct mpath_node *gate;
479 struct hlist_node *p, *q; 474 struct hlist_node *p, *q;
480 475
481 tbl = rcu_dereference(tbl);
482
483 hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list) 476 hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list)
484 if (gate->mpath == mpath) { 477 if (gate->mpath == mpath) {
485 spin_lock_bh(&tbl->gates_lock); 478 spin_lock_bh(&tbl->gates_lock);
@@ -498,16 +491,6 @@ static int mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
498} 491}
499 492
500/** 493/**
501 *
502 * mesh_path_add_gate - add the given mpath to a mesh gate to our path table
503 * @mpath: gate path to add to table
504 */
505int mesh_path_add_gate(struct mesh_path *mpath)
506{
507 return mesh_gate_add(mesh_paths, mpath);
508}
509
510/**
511 * mesh_gate_num - number of gates known to this interface 494 * mesh_gate_num - number of gates known to this interface
512 * @sdata: subif data 495 * @sdata: subif data
513 */ 496 */