irda: Fix RCU lock pairing on error path
Subsystems (2)
PATCH 1/1 irda: Fix RCU lock pairing on error path
irlan_client_discovery_indication calls rcu_read_lock and rcu_read_unlock, but returns without unlocking in an error case. Fix that by replacing the return with a goto so that the rcu_read_unlock always gets executed.
---
net/irda/irlan/irlan_client.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
e20ab96944814489277c3bfd4e69133854ab01e9
net/irda/irlan/irlan_client.c +2 -1
@@ -173,13 +173,14 @@ void irlan_client_discovery_indication(drcu_read_lock (); self =irlan_get_any ();if (self) { - IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); + IRDA_ASSERT(self->magic == IRLAN_MAGIC, goto out;);IRDA_DEBUG (1 ,"%s(), Found instance (%08x)!\n" , __FUNCTION__ , daddr);irlan_client_wakeup (self, saddr, daddr); } +out:rcu_read_unlock (); }
Quoted 3 lines · Josh Triplett
irlan_client_discovery_indicationcallsrcu_read_lockandrcu_read_unlock, but returns without unlocking in an error case. Fix that by replacing the return with a goto so that thercu_read_unlockalways gets executed.
Good catch!!! Looks good from an RCU viewpoint, in fact, looks absolutely necessary to permit IRDA to work in debug mode, particularly in either a CONFIG_PREEMPT or a -rt kernel.
One question below, but up to the maintainer. ;-)
Thanx, Paul
Quoted 15 lines
Signed-off-by Josh Triplett <[email protected]>---
net/irda/irlan/irlan_client.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
e20ab96944814489277c3bfd4e69133854ab01e9net/irda/irlan/irlan_client.c +0
-0@@ -173,13 +173,14 @@ void irlan_client_discovery_indication(drcu_read_lock (); self =irlan_get_any ();
net/irda/irlan/irlan_client.c void irlan_client_discovery_indication(d · line 183
Quoted 10 lines
net/irda/irlan/irlan_client.c +2
-1if (self) { - IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); + IRDA_ASSERT(self->magic == IRLAN_MAGIC, goto out;);IRDA_DEBUG (1 ,"%s(), Found instance (%08x)!\n" , __FUNCTION__ , daddr);irlan_client_wakeup (self, saddr, daddr); } +out:
Should the above label instead be as follows?
IRDA_ASSERT_LABEL(out:)
Just in case some variant of gcc, sparse, or whatever complains about labels that don't have a corresponding goto (in CONFIG_IRDA_DEBUG=n builds).
Quoted 5 lines
net/irda/irlan/irlan_client.c +0
-0rcu_read_unlock (); }
Hi Paul, hi Josh,
Quoted 10 lines · Paul E. McKenney
Quoted 5 lines · Josh Triplett
irlan_client_discovery_indicationcallsrcu_read_lockandrcu_read_unlock, but
returns without unlocking in an error case. Fix that by replacing the return
with a goto so that thercu_read_unlockalways gets executed.Good catch!!! Looks good from an RCU viewpoint, in fact, looks absolutely necessary to permit IRDA to work in debug mode, particularly in either a
CONFIG_PREEMPTor a -rt kernel.
Indeed, nice catch.
Quoted 1 line
One question below, but up to the maintainer. ;-)
Yes, definitely, IRDA_ASSERT_LABEL(out:) makes sense. I will forward the patch to davem's netdev tree, thanks.
Cheers,
Samuel.
Quoted 44 lines
Thanx, Paul
Acked-by Paul E. McKenney <[email protected]>Quoted 16 lines
Signed-off-by Josh Triplett <[email protected]>---
net/irda/irlan/irlan_client.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
e20ab96944814489277c3bfd4e69133854ab01e9net/irda/irlan/irlan_client.c +0
-0@@ -173,13 +173,14 @@ void irlan_client_discovery_indication(drcu_read_lock (); self =irlan_get_any ();net/irda/irlan/irlan_client.c void irlan_client_discovery_indication(d · line 183
Quoted 10 lines
net/irda/irlan/irlan_client.c +2
-1if (self) { - IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); + IRDA_ASSERT(self->magic == IRLAN_MAGIC, goto out;);IRDA_DEBUG (1 ,"%s(), Found instance (%08x)!\n" , __FUNCTION__ , daddr);irlan_client_wakeup (self, saddr, daddr); } +out:Should the above label instead be as follows?
IRDA_ASSERT_LABEL(out:)Just in case some variant of gcc, sparse, or whatever complains about labels that don't have a corresponding goto (in
CONFIG_IRDA_DEBUG=nbuilds).Quoted 5 lines
net/irda/irlan/irlan_client.c +0
-0rcu_read_unlock (); }
PATCH 1/2 Fix RCU lock pairing on error path
In reply to Paul E. McKenneyHi Dave,
irlan_client_discovery_indication calls rcu_read_lock and rcu_read_unlock, but returns without unlocking in an error case. Fix that by replacing the return with a goto so that the rcu_read_unlock always gets executed.
--- net/irda/irlan/irlan_client.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
net/irda/irlan/irlan_client.c +2 -1
@@ -173,13 +173,14 @@ void irlan_client_discovery_indication(drcu_read_lock (); self =irlan_get_any ();if (self) { - IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); + IRDA_ASSERT(self->magic == IRLAN_MAGIC, goto out;);IRDA_DEBUG (1 ,"%s(), Found instance (%08x)!\n" , __FUNCTION__ , daddr);irlan_client_wakeup (self, saddr, daddr); } +IRDA_ASSERT_LABEL(out:)rcu_read_unlock (); }
Signature · 1 line
1.4.0
Re: [PATCH 1/2] [IrDA] Fix RCU lock pairing on error path
From: Samuel Ortiz <[email protected]>
Date: Fri, 30 Jun 2006 09:55:34 +0300
Quoted 7 lines
irlan_client_discovery_indicationcallsrcu_read_lockandrcu_read_unlock, but returns without unlocking in an error case. Fix that by replacing the return with a goto so that thercu_read_unlockalways gets executed.Signed-off-by Josh Triplett <[email protected]>Signed-off-by Samuel Ortiz [email protected] <>
Applied, thanks.
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
From: Josh Triplett <[email protected]>
Date: Wed, 28 Jun 2006 17:56:41 -0700
Quoted 5 lines
irlan_client_discovery_indicationcallsrcu_read_lockandrcu_read_unlock, but returns without unlocking in an error case. Fix that by replacing the return with a goto so that thercu_read_unlockalways gets executed.Signed-off-by Josh Triplett <[email protected]>
Applied, thanks a lot.