]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: MGMT: Add error handling to pair_device()
authorGriffin Kroah-Hartman <griffin@kroah.com>
Thu, 15 Aug 2024 11:51:00 +0000 (13:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2024 15:36:06 +0000 (17:36 +0200)
commit 538fd3921afac97158d4177139a0ad39f056dbb2 upstream.

hci_conn_params_add() never checks for a NULL value and could lead to a NULL
pointer dereference causing a crash.

Fixed by adding error handling in the function.

Cc: Stable <stable@kernel.org>
Fixes: 5157b8a503fa ("Bluetooth: Fix initializing conn_params in scan phase")
Signed-off-by: Griffin Kroah-Hartman <griffin@kroah.com>
Reported-by: Yiwei Zhang <zhan4630@purdue.edu>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/bluetooth/mgmt.c

index 80f220b7e19d5560df42e807c20c70622e3bc205..ad4793ea052df9671c9ffb04aad5dbc18561192d 100644 (file)
@@ -3457,6 +3457,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
                 * will be kept and this function does nothing.
                 */
                p = hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type);
+               if (!p) {
+                       err = -EIO;
+                       goto unlock;
+               }
 
                if (p->auto_connect == HCI_AUTO_CONN_EXPLICIT)
                        p->auto_connect = HCI_AUTO_CONN_DISABLED;