提交 c51ffa0b 编写于 作者: J Johan Hedberg 提交者: Marcel Holtmann

Bluetooth: Fix hci_remove_ltk failure when no match is found

There is code (in mgmt.c) that depends on the hci_remove_ltk function to
fail if no match is found. This patch adds tracking of removed LTKs
(there can be up to two: one for master and another for slave) in the
hci_remove_ltk function and returns -ENOENT of no matches were found.
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 35f7498a
...@@ -2807,6 +2807,7 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) ...@@ -2807,6 +2807,7 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type) int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
{ {
struct smp_ltk *k, *tmp; struct smp_ltk *k, *tmp;
int removed = 0;
list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) { list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) {
if (bacmp(bdaddr, &k->bdaddr) || k->bdaddr_type != bdaddr_type) if (bacmp(bdaddr, &k->bdaddr) || k->bdaddr_type != bdaddr_type)
...@@ -2816,9 +2817,10 @@ int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type) ...@@ -2816,9 +2817,10 @@ int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
list_del(&k->list); list_del(&k->list);
kfree(k); kfree(k);
removed++;
} }
return 0; return removed ? 0 : -ENOENT;
} }
/* HCI command timer function */ /* HCI command timer function */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册