diff mbox

bluetooth: fix error cases

Message ID 1306910377.3867.5.camel@jlt3.sipsolutions.net (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Johannes Berg June 1, 2011, 6:39 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

The error cases in a few functions can use a
socket variable that was never initialised,
gcc correctly warns about this:
net/bluetooth/l2cap_core.c: In function ‘l2cap_recv_frame’:
include/linux/spinlock.h:325:19: warning: ‘sk’ may be used uninitialized in this function [-Wuninitialized]
net/bluetooth/l2cap_core.c:3789:15: note: ‘sk’ was declared here
include/linux/spinlock.h:325:19: warning: ‘sk’ may be used uninitialized in this function [-Wuninitialized]
net/bluetooth/l2cap_core.c:3756:15: note: ‘sk’ was declared here

Initialise the socket to NULL as clearly intended
by the error handling code.

Also fix a "set but not used" warning.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/bluetooth/l2cap_core.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

John W. Linville June 1, 2011, 6:40 p.m. UTC | #1
On Wed, Jun 01, 2011 at 08:39:37AM +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> The error cases in a few functions can use a
> socket variable that was never initialised,
> gcc correctly warns about this:
> net/bluetooth/l2cap_core.c: In function ‘l2cap_recv_frame’:
> include/linux/spinlock.h:325:19: warning: ‘sk’ may be used uninitialized in this function [-Wuninitialized]
> net/bluetooth/l2cap_core.c:3789:15: note: ‘sk’ was declared here
> include/linux/spinlock.h:325:19: warning: ‘sk’ may be used uninitialized in this function [-Wuninitialized]
> net/bluetooth/l2cap_core.c:3756:15: note: ‘sk’ was declared here
> 
> Initialise the socket to NULL as clearly intended
> by the error handling code.
> 
> Also fix a "set but not used" warning.
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Dave fixed part of these a couple of weeks ago:

commit 6dcae1eaee2b437536b2fe928a609f9589691ebf
Author: David S. Miller <davem@davemloft.net>
Date:   Mon May 16 23:09:26 2011 -0400

    bluetooth: Fix warnings in l2cap_core.c
    
    net/bluetooth/l2cap_core.c: In function ‘l2cap_recv_frame’:
    net/bluetooth/l2cap_core.c:3758:15: warning: ‘sk’ may be used uninitialized 
    net/bluetooth/l2cap_core.c:3758:15: note: ‘sk’ was declared here
    net/bluetooth/l2cap_core.c:3791:15: warning: ‘sk’ may be used uninitialized 
    net/bluetooth/l2cap_core.c:3791:15: note: ‘sk’ was declared here
    
    Signed-off-by: David S. Miller <davem@davemloft.net>

The "set but not used" bit still applies...
Gustavo F. Padovan June 1, 2011, 6:48 p.m. UTC | #2
* John W. Linville <linville@tuxdriver.com> [2011-06-01 14:40:37 -0400]:

> On Wed, Jun 01, 2011 at 08:39:37AM +0200, Johannes Berg wrote:
> > From: Johannes Berg <johannes.berg@intel.com>
> > 
> > The error cases in a few functions can use a
> > socket variable that was never initialised,
> > gcc correctly warns about this:
> > net/bluetooth/l2cap_core.c: In function ‘l2cap_recv_frame’:
> > include/linux/spinlock.h:325:19: warning: ‘sk’ may be used uninitialized in this function [-Wuninitialized]
> > net/bluetooth/l2cap_core.c:3789:15: note: ‘sk’ was declared here
> > include/linux/spinlock.h:325:19: warning: ‘sk’ may be used uninitialized in this function [-Wuninitialized]
> > net/bluetooth/l2cap_core.c:3756:15: note: ‘sk’ was declared here
> > 
> > Initialise the socket to NULL as clearly intended
> > by the error handling code.
> > 
> > Also fix a "set but not used" warning.
> > 
> > Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> 
> Dave fixed part of these a couple of weeks ago:
> 
> commit 6dcae1eaee2b437536b2fe928a609f9589691ebf
> Author: David S. Miller <davem@davemloft.net>
> Date:   Mon May 16 23:09:26 2011 -0400
> 
>     bluetooth: Fix warnings in l2cap_core.c
>     
>     net/bluetooth/l2cap_core.c: In function ‘l2cap_recv_frame’:
>     net/bluetooth/l2cap_core.c:3758:15: warning: ‘sk’ may be used uninitialized 
>     net/bluetooth/l2cap_core.c:3758:15: note: ‘sk’ was declared here
>     net/bluetooth/l2cap_core.c:3791:15: warning: ‘sk’ may be used uninitialized 
>     net/bluetooth/l2cap_core.c:3791:15: note: ‘sk’ was declared here
>     
>     Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> The "set but not used" bit still applies...

Those are fixed in my -next tree now.
diff mbox

Patch

--- a/net/bluetooth/l2cap_core.c	2011-06-01 08:33:36.000000000 +0200
+++ b/net/bluetooth/l2cap_core.c	2011-06-01 08:34:35.000000000 +0200
@@ -3667,7 +3667,6 @@  static inline int l2cap_data_channel(str
 {
 	struct l2cap_chan *chan;
 	struct sock *sk = NULL;
-	struct l2cap_pinfo *pi;
 	u16 control;
 	u8 tx_seq;
 	int len;
@@ -3679,7 +3678,6 @@  static inline int l2cap_data_channel(str
 	}
 
 	sk = chan->sk;
-	pi = l2cap_pi(sk);
 
 	BT_DBG("chan %p, len %d", chan, skb->len);
 
@@ -3755,7 +3753,7 @@  done:
 
 static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, struct sk_buff *skb)
 {
-	struct sock *sk;
+	struct sock *sk = NULL;
 	struct l2cap_chan *chan;
 
 	chan = l2cap_global_chan_by_psm(0, psm, conn->src);
@@ -3788,7 +3786,7 @@  done:
 
 static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct sk_buff *skb)
 {
-	struct sock *sk;
+	struct sock *sk = NULL;
 	struct l2cap_chan *chan;
 
 	chan = l2cap_global_chan_by_scid(0, cid, conn->src);