From patchwork Wed Jun 1 06:39:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 834922 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p516dkC2012709 for ; Wed, 1 Jun 2011 06:39:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754249Ab1FAGjn (ORCPT ); Wed, 1 Jun 2011 02:39:43 -0400 Received: from he.sipsolutions.net ([78.46.109.217]:42096 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752829Ab1FAGjm (ORCPT ); Wed, 1 Jun 2011 02:39:42 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1QRf5f-0002dT-RI; Wed, 01 Jun 2011 08:39:39 +0200 Subject: [PATCH] bluetooth: fix error cases From: Johannes Berg To: John Linville Cc: "Gustavo F. Padovan" , linux-wireless , linux-bluetooth@vger.kernel.org Date: Wed, 01 Jun 2011 08:39:37 +0200 Message-ID: <1306910377.3867.5.camel@jlt3.sipsolutions.net> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 01 Jun 2011 06:39:46 +0000 (UTC) From: Johannes Berg 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 --- 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 --- 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);