Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: hci_sync: make hci_cmd_sync_run_once return -EEXIST if exists

hci_cmd_sync_run_once() needs to indicate whether a queue item was
added, so caller can know if callbacks are called, so it can avoid
leaking resources.

Change the function to return -EEXIST if queue item already exists.

Modify all callsites vs. the changes. The only callsite is
hci_abort_conn().

Signed-off-by: Pauli Virtanen <pav@iki.fi>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Pauli Virtanen and committed by
Luiz Augusto von Dentz
d288f4db 7b758678

+4 -2
+3 -1
net/bluetooth/hci_conn.c
··· 3083 3083 int hci_abort_conn(struct hci_conn *conn, u8 reason) 3084 3084 { 3085 3085 struct hci_dev *hdev = conn->hdev; 3086 + int err; 3086 3087 3087 3088 /* If abort_reason has already been set it means the connection is 3088 3089 * already being aborted so don't attempt to overwrite it. ··· 3120 3119 * as a result to MGMT_OP_DISCONNECT/MGMT_OP_UNPAIR which does 3121 3120 * already queue its callback on cmd_sync_work. 3122 3121 */ 3123 - return hci_cmd_sync_run_once(hdev, abort_conn_sync, conn, NULL); 3122 + err = hci_cmd_sync_run_once(hdev, abort_conn_sync, conn, NULL); 3123 + return (err == -EEXIST) ? 0 : err; 3124 3124 } 3125 3125 3126 3126 void hci_setup_tx_timestamp(struct sk_buff *skb, size_t key_offset,
+1 -1
net/bluetooth/hci_sync.c
··· 825 825 void *data, hci_cmd_sync_work_destroy_t destroy) 826 826 { 827 827 if (hci_cmd_sync_lookup_entry(hdev, func, data, destroy)) 828 - return 0; 828 + return -EEXIST; 829 829 830 830 return hci_cmd_sync_run(hdev, func, data, destroy); 831 831 }