]> Pileus Git - ~andy/linux/commitdiff
Bluetooth: Fix hci_connect error return values
authorJohan Hedberg <johan.hedberg@intel.com>
Sun, 19 Feb 2012 12:06:48 +0000 (14:06 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Sun, 19 Feb 2012 12:22:11 +0000 (14:22 +0200)
The hci_connect function should either return a valid hci_conn pointer
or a ERR_PTR() but never NULL. This patch fixes the two places where
hci_conn_add failures would have caused a NULL return. The only reason
for failure with hci_conn_add is memory allocation so ENOMEM seems to be
a good choice here.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_conn.c

index 7ee6895c4b0c56c69650bfb560dd2d489219cf90..8549d04e33133ab98db3c783c55bfdc0cb2811a9 100644 (file)
@@ -551,7 +551,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
        if (!acl) {
                acl = hci_conn_add(hdev, ACL_LINK, dst);
                if (!acl)
-                       return NULL;
+                       return ERR_PTR(-ENOMEM);
        }
 
        hci_conn_hold(acl);
@@ -571,7 +571,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
                sco = hci_conn_add(hdev, type, dst);
                if (!sco) {
                        hci_conn_put(acl);
-                       return NULL;
+                       return ERR_PTR(-ENOMEM);
                }
        }