[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240815115100.13100-1-griffin@kroah.com>
Date: Thu, 15 Aug 2024 13:51:00 +0200
From: Griffin Kroah-Hartman <griffin@...ah.com>
To: marcel@...tmann.org,
johan.hedberg@...il.com,
luiz.dentz@...il.com
Cc: linux-bluetooth@...r.kernel.org,
linux-kernel@...r.kernel.org,
Griffin Kroah-Hartman <griffin@...ah.com>,
Yiwei Zhang <zhan4630@...due.edu>,
Stable <stable@...nel.org>
Subject: [PATCH] Bluetooth: MGMT: Add error handling to pair_device()
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.
Reported-by: Yiwei Zhang <zhan4630@...due.edu>
Cc: Stable <stable@...nel.org>
Fixes: 5157b8a503fa ("Bluetooth: Fix initializing conn_params in scan phase")
Signed-off-by: Griffin Kroah-Hartman <griffin@...ah.com>
---
net/bluetooth/mgmt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 40d4887c7f79..25979f4283a6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3456,6 +3456,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;
--
2.46.0
Powered by blists - more mailing lists