netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net, bluetooth: don't attempt to free a channel that wasn't created
@ 2012-10-04 23:59 Sasha Levin
       [not found] ` <1349395197-12395-1-git-send-email-sasha.levin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2012-10-04 23:59 UTC (permalink / raw)
  To: marcel, gustavo, johan.hedberg, davem
  Cc: levinsasha928, davej, linux-kernel, linux-bluetooth, netdev,
	Sasha Levin

We may currently attempt to free a channel which wasn't created due to
an error in the initialization path, this would cause a NULL ptr deref.

Introduced in commit 61d6ef3e ("Bluetooth: Make better use of l2cap_chan
reference counting").

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/bluetooth/l2cap_sock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 083f2bf..66c295a 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1083,7 +1083,8 @@ static void l2cap_sock_destruct(struct sock *sk)
 {
 	BT_DBG("sk %p", sk);
 
-	l2cap_chan_put(l2cap_pi(sk)->chan);
+	if (l2cap_pi(sk)->chan)
+		l2cap_chan_put(l2cap_pi(sk)->chan);
 	if (l2cap_pi(sk)->rx_busy_skb) {
 		kfree_skb(l2cap_pi(sk)->rx_busy_skb);
 		l2cap_pi(sk)->rx_busy_skb = NULL;
-- 
1.7.12

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

end of thread, other threads:[~2012-10-07 21:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-04 23:59 [PATCH] net, bluetooth: don't attempt to free a channel that wasn't created Sasha Levin
     [not found] ` <1349395197-12395-1-git-send-email-sasha.levin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-10-05 10:22   ` Andrei Emeltchenko
2012-10-05 15:09     ` Sasha Levin
     [not found]       ` <506EF827.3060100-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-10-05 18:53         ` Andrei Emeltchenko
2012-10-07 21:41         ` Gustavo 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).