Skip to contentSkip to conversation

nf_nat_h323.c unneeded rcu_dereference() calls

PATCH Applied Paul E. McKenney 2 participants 3 messages Oct 29, 2007 – Oct 30, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nf_nat_h323.c unneeded rcu_dereference() calls

Hello!

While reviewing rcu_dereference() uses, I came across a number of cases where I couldn't see how the rcu_dereference() helped. One class of cases is where the variable is never subsequently dereferenced, so that patches like the following one would be appropriate.

So, what am I missing here?

---

 nf_nat_h323.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
net/ipv4/netfilter/nf_nat_h323.c +9 -9
diff -urpNa -X dontdiff linux-2.6.23/net/ipv4/netfilter/nf_nat_h323.c linux-2.6.23-rcufix/net/ipv4/netfilter/nf_nat_h323.c
@@ -546,15 +546,15 @@ static int nat_callforwarding(struct sk_
 /****************************************************************************/
 static int __init init(void)
 {
-	BUG_ON(rcu_dereference(set_h245_addr_hook) != NULL);
-	BUG_ON(rcu_dereference(set_h225_addr_hook) != NULL);
-	BUG_ON(rcu_dereference(set_sig_addr_hook) != NULL);
-	BUG_ON(rcu_dereference(set_ras_addr_hook) != NULL);
-	BUG_ON(rcu_dereference(nat_rtp_rtcp_hook) != NULL);
-	BUG_ON(rcu_dereference(nat_t120_hook) != NULL);
-	BUG_ON(rcu_dereference(nat_h245_hook) != NULL);
-	BUG_ON(rcu_dereference(nat_callforwarding_hook) != NULL);
-	BUG_ON(rcu_dereference(nat_q931_hook) != NULL);
+	BUG_ON(set_h245_addr_hook != NULL);
+	BUG_ON(set_h225_addr_hook != NULL);
+	BUG_ON(set_sig_addr_hook != NULL);
+	BUG_ON(set_ras_addr_hook != NULL);
+	BUG_ON(nat_rtp_rtcp_hook != NULL);
+	BUG_ON(nat_t120_hook != NULL);
+	BUG_ON(nat_h245_hook != NULL);
+	BUG_ON(nat_callforwarding_hook != NULL);
+	BUG_ON(nat_q931_hook != NULL);
 
 	rcu_assign_pointer(set_h245_addr_hook, set_h245_addr);
 	rcu_assign_pointer(set_h225_addr_hook, set_h225_addr);
#1 lore raw
Quoted 8 lines · Paul E. McKenney

Hello!

While reviewing rcu_dereference() uses, I came across a number of cases where I couldn't see how the rcu_dereference() helped. One class of cases is where the variable is never subsequently dereferenced, so that patches like the following one would be appropriate.

So, what am I missing here?

Nothing, it was mainly intended as documentation that the hooks are protected by RCU. I agree that its probably more confusing this way since we're not even in a rcu_read_lock protected section.

I've queued a patch to remove them all.

#2 lore raw
Quoted 8 lines · Patrick McHardy
Quoted 7 lines · Paul E. McKenney

Hello!

While reviewing rcu_dereference() uses, I came across a number of cases where I couldn't see how the rcu_dereference() helped. One class of cases is where the variable is never subsequently dereferenced, so that patches like the following one would be appropriate.

Quoted 7 lines
Quoted 1 line

So, what am I missing here?

Nothing, it was mainly intended as documentation that the hooks are protected by RCU. I agree that its probably more confusing this way since we're not even in a rcu_read_lock protected section.

I've queued a patch to remove them all.

Thank you!!!

Thanx, Paul