]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Bluetooth: Fix potential NULL dereference
authorJohan Hedberg <johan.hedberg@intel.com>
Tue, 3 Feb 2015 08:01:13 +0000 (10:01 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 3 Feb 2015 08:02:12 +0000 (09:02 +0100)
The bnep_get_device function may be triggered by an ioctl just after a
connection has gone down. In such a case the respective L2CAP chan->conn
pointer will get set to NULL (by l2cap_chan_del). This patch adds a
missing NULL check for this case in the bnep_get_device() function.

Reported-by: Patrik Flykt <patrik.flykt@linux.intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/bnep/core.c

index ce82722d049b7c013fd06f66f726fbbf75a01f56..05f57e491ccbd614a1d306c49df891e4a2ec00c6 100644 (file)
@@ -511,13 +511,12 @@ static int bnep_session(void *arg)
 
 static struct device *bnep_get_device(struct bnep_session *session)
 {
-       struct hci_conn *conn;
+       struct l2cap_conn *conn = l2cap_pi(session->sock->sk)->chan->conn;
 
-       conn = l2cap_pi(session->sock->sk)->chan->conn->hcon;
-       if (!conn)
+       if (!conn || !conn->hcon)
                return NULL;
 
-       return &conn->dev;
+       return &conn->hcon->dev;
 }
 
 static struct device_type bnep_type = {