Skip to content

Commit a27c519

Browse files
JackieLiu1holtmann
authored andcommitted
Bluetooth: fix uninitialized variables notify_evt
Coverity Scan report: [...] *** CID 1493985: Uninitialized variables (UNINIT) /net/bluetooth/hci_event.c: 4535 in hci_sync_conn_complete_evt() 4529 4530 /* Notify only in case of SCO over HCI transport data path which 4531 * is zero and non-zero value shall be non-HCI transport data path 4532 */ 4533 if (conn->codec.data_path == 0) { 4534 if (hdev->notify) >>> CID 1493985: Uninitialized variables (UNINIT) >>> Using uninitialized value "notify_evt" when calling "*hdev->notify". 4535 hdev->notify(hdev, notify_evt); 4536 } 4537 4538 hci_connect_cfm(conn, ev->status); 4539 if (ev->status) 4540 hci_conn_del(conn); [...] Although only btusb uses air_mode, and he only handles HCI_NOTIFY_ENABLE_SCO_CVSD and HCI_NOTIFY_ENABLE_SCO_TRANSP, there is still a very small chance that ev->air_mode is not equal to 0x2 and 0x3, but notify_evt is initialized to HCI_NOTIFY_ENABLE_SCO_CVSD or HCI_NOTIFY_ENABLE_SCO_TRANSP. the context is maybe not correct. Let us directly use the required function instead of re-initializing it, so as to restore the original logic and make the code more correct. Addresses-Coverity: ("Uninitialized variables") Fixes: f4f9fa0 ("Bluetooth: Allow usb to auto-suspend when SCO use non-HCI transport") Suggested-by: Marcel Holtmann <[email protected]> Signed-off-by: Jackie Liu <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 3a56ef7 commit a27c519

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

net/bluetooth/hci_event.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4530,7 +4530,6 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
45304530
{
45314531
struct hci_ev_sync_conn_complete *ev = (void *) skb->data;
45324532
struct hci_conn *conn;
4533-
unsigned int notify_evt;
45344533

45354534
BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
45364535

@@ -4602,22 +4601,18 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
46024601
}
46034602

46044603
bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode);
4605-
4606-
switch (ev->air_mode) {
4607-
case 0x02:
4608-
notify_evt = HCI_NOTIFY_ENABLE_SCO_CVSD;
4609-
break;
4610-
case 0x03:
4611-
notify_evt = HCI_NOTIFY_ENABLE_SCO_TRANSP;
4612-
break;
4613-
}
4614-
46154604
/* Notify only in case of SCO over HCI transport data path which
46164605
* is zero and non-zero value shall be non-HCI transport data path
46174606
*/
4618-
if (conn->codec.data_path == 0) {
4619-
if (hdev->notify)
4620-
hdev->notify(hdev, notify_evt);
4607+
if (conn->codec.data_path == 0 && hdev->notify) {
4608+
switch (ev->air_mode) {
4609+
case 0x02:
4610+
hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD);
4611+
break;
4612+
case 0x03:
4613+
hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP);
4614+
break;
4615+
}
46214616
}
46224617

46234618
hci_connect_cfm(conn, ev->status);

0 commit comments

Comments
 (0)