Bluetooth: hci_conn: Check non NULL function before calling for HFP offload
authorZijun Hu <quic_zijuhu@quicinc.com>
Fri, 8 Dec 2023 01:51:26 +0000 (09:51 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 22 Dec 2023 17:57:24 +0000 (12:57 -0500)
For some controllers such as QCA2066, it does not need to send
HCI_Configure_Data_Path to configure non-HCI data transport path to support
HFP offload, their device drivers may set hdev->get_codec_config_data as
NULL, so Explicitly add this non NULL checking before calling the function.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_conn.c

index a134081830224d8b7e30f1d3210966d00dd6b432..a41d2693f4d8c795c00e8df069c5fb90c7eb87c7 100644 (file)
@@ -300,6 +300,13 @@ static int configure_datapath_sync(struct hci_dev *hdev, struct bt_codec *codec)
        __u8 vnd_len, *vnd_data = NULL;
        struct hci_op_configure_data_path *cmd = NULL;
 
+       if (!codec->data_path || !hdev->get_codec_config_data)
+               return 0;
+
+       /* Do not take me as error */
+       if (!hdev->get_codec_config_data)
+               return 0;
+
        err = hdev->get_codec_config_data(hdev, ESCO_LINK, codec, &vnd_len,
                                          &vnd_data);
        if (err < 0)
@@ -345,9 +352,7 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)
 
        bt_dev_dbg(hdev, "hcon %p", conn);
 
-       /* for offload use case, codec needs to configured before opening SCO */
-       if (conn->codec.data_path)
-               configure_datapath_sync(hdev, &conn->codec);
+       configure_datapath_sync(hdev, &conn->codec);
 
        conn->state = BT_CONNECT;
        conn->out = true;