Bluetooth: Fix wrong module refcount when connection setup fails
[pandora-kernel.git] / net / bluetooth / hci_conn.c
index 1181db0..85a1c6b 100644 (file)
@@ -215,6 +215,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
        conn->state = BT_OPEN;
 
        conn->power_save = 1;
+       conn->disc_timeout = HCI_DISCONN_TIMEOUT;
 
        switch (type) {
        case ACL_LINK:
@@ -247,6 +248,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
        if (hdev->notify)
                hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
 
+       hci_conn_init_sysfs(conn);
+
        tasklet_enable(&hdev->tx_task);
 
        return conn;
@@ -289,6 +292,8 @@ int hci_conn_del(struct hci_conn *conn)
 
        hci_conn_del_sysfs(conn);
 
+       hci_dev_put(hdev);
+
        return 0;
 }
 
@@ -424,12 +429,9 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
        if (sec_level == BT_SECURITY_SDP)
                return 1;
 
-       if (sec_level == BT_SECURITY_LOW) {
-               if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0)
-                       return hci_conn_auth(conn, sec_level, auth_type);
-               else
-                       return 1;
-       }
+       if (sec_level == BT_SECURITY_LOW &&
+                               (!conn->ssp_mode || !conn->hdev->ssp_mode))
+               return 1;
 
        if (conn->link_mode & HCI_LM_ENCRYPT)
                return hci_conn_auth(conn, sec_level, auth_type);