Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Fix hci_connect error return values

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>

+2 -2
+2 -2
net/bluetooth/hci_conn.c
··· 551 551 if (!acl) { 552 552 acl = hci_conn_add(hdev, ACL_LINK, dst); 553 553 if (!acl) 554 - return NULL; 554 + return ERR_PTR(-ENOMEM); 555 555 } 556 556 557 557 hci_conn_hold(acl); ··· 571 571 sco = hci_conn_add(hdev, type, dst); 572 572 if (!sco) { 573 573 hci_conn_put(acl); 574 - return NULL; 574 + return ERR_PTR(-ENOMEM); 575 575 } 576 576 } 577 577