linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bluetooth: fix error cases
@ 2011-06-01  6:39 Johannes Berg
  2011-06-01 18:40 ` John W. Linville
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2011-06-01  6:39 UTC (permalink / raw)
  To: John Linville; +Cc: Gustavo F. Padovan, linux-wireless, linux-bluetooth

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(-)

--- 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);



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-01 18:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-01  6:39 [PATCH] bluetooth: fix error cases Johannes Berg
2011-06-01 18:40 ` John W. Linville
2011-06-01 18:48   ` Gustavo F. Padovan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).