Skip to content

Commit ee802a4

Browse files
author
Paolo Abeni
committed
Merge tag 'for-net-2024-10-30' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - hci: fix null-ptr-deref in hci_read_supported_codecs * tag 'for-net-2024-10-30' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: hci: fix null-ptr-deref in hci_read_supported_codecs ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents d80a309 + 1e67d86 commit ee802a4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

net/bluetooth/hci_sync.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
206206
return ERR_PTR(err);
207207
}
208208

209+
/* If command return a status event skb will be set to NULL as there are
210+
* no parameters.
211+
*/
212+
if (!skb)
213+
return ERR_PTR(-ENODATA);
214+
209215
return skb;
210216
}
211217
EXPORT_SYMBOL(__hci_cmd_sync_sk);
@@ -255,20 +261,18 @@ int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
255261
u8 status;
256262

257263
skb = __hci_cmd_sync_sk(hdev, opcode, plen, param, event, timeout, sk);
264+
265+
/* If command return a status event, skb will be set to -ENODATA */
266+
if (skb == ERR_PTR(-ENODATA))
267+
return 0;
268+
258269
if (IS_ERR(skb)) {
259270
if (!event)
260271
bt_dev_err(hdev, "Opcode 0x%4.4x failed: %ld", opcode,
261272
PTR_ERR(skb));
262273
return PTR_ERR(skb);
263274
}
264275

265-
/* If command return a status event skb will be set to NULL as there are
266-
* no parameters, in case of failure IS_ERR(skb) would have be set to
267-
* the actual error would be found with PTR_ERR(skb).
268-
*/
269-
if (!skb)
270-
return 0;
271-
272276
status = skb->data[0];
273277

274278
kfree_skb(skb);

0 commit comments

Comments
 (0)