]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: Add check for mgmt_alloc_skb() in mgmt_remote_name()
authorHaoxiang Li <haoxiang_li2024@163.com>
Fri, 21 Feb 2025 08:49:47 +0000 (16:49 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 27 Feb 2025 21:50:24 +0000 (16:50 -0500)
Add check for the return value of mgmt_alloc_skb() in
mgmt_remote_name() to prevent null pointer dereference.

Fixes: ba17bb62ce41 ("Bluetooth: Fix skb allocation in mgmt_remote_name() & mgmt_device_connected()")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/mgmt.c

index f53304cb09dbeadc8a55054061ccbea58cb3970e..3e0f88cd975c80f44d7e2cfe8a4f735ac579e8b8 100644 (file)
@@ -10413,6 +10413,8 @@ void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 
        skb = mgmt_alloc_skb(hdev, MGMT_EV_DEVICE_FOUND,
                             sizeof(*ev) + (name ? eir_precalc_len(name_len) : 0));
+       if (!skb)
+               return;
 
        ev = skb_put(skb, sizeof(*ev));
        bacpy(&ev->addr.bdaddr, bdaddr);