Search Linux Wireless

[PATCH] bluetooth: fix error cases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johannes Berg <johannes.berg@xxxxxxxxx>

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


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


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux