Bluetooth: Fix potential NULL dereference
[deliverable/linux.git] / 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 = {
This page took 0.027892 seconds and 5 git commands to generate.