Skip to contentSkip to conversation

Bluetooth: btmtk: adjust the position to init iso data anchor

PATCH Superseded Chris Lu 2 participants 3 messages Oct 23, 2024 – Oct 25, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chris Lu

author
#0 lore raw

PATCH 1/1 Bluetooth: btmtk: adjust the position to init iso data anchor

MediaTek iso data anchor init should be move to where MediaTek claims iso data interface.
If there is an unexpected usb disconnect during setup flow, it will cause a NULL pointer crash issue when releasing iso anchor since the anchor wan't been init yet. Adjust the position to do iso data anchor init.

---
 drivers/bluetooth/btmtk.c | 1 -
 drivers/bluetooth/btusb.c | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/btmtk.c +0 -1
index b7fc14aafc74..8a3f7c3fcfec 100644
@@ -1215,7 +1215,6 @@ static int btmtk_usb_isointf_init(struct hci_dev *hdev)
 	struct sk_buff *skb;
 	int err;
 
-	init_usb_anchor(&btmtk_data->isopkt_anchor);
 	spin_lock_init(&btmtk_data->isorxlock);
 
 	__set_mtk_intr_interface(hdev);
drivers/bluetooth/btusb.c +2 -0
index 9970470c9d15..15c0885c37cd 100644
@@ -2628,6 +2628,8 @@ static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
 	struct btmtk_data *btmtk_data = hci_get_priv(data->hdev);
 	int err;
 
+	init_usb_anchor(&btmtk_data->isopkt_anchor);
+
 	err = usb_driver_claim_interface(&btusb_driver,
 					 btmtk_data->isopkt_intf, data);
 	if (err < 0) {
Signature · 1 line
2.18.0
#1 lore raw

Hi Chris,

Quoted 9 lines · Chris Lu

MediaTek iso data anchor init should be move to where MediaTek claims iso data interface.
If there is an unexpected usb disconnect during setup flow, it will cause a NULL pointer crash issue when releasing iso anchor since the anchor wan't been init yet. Adjust the position to do iso data anchor init.

Please add the backtrace or a Link tag if there is an issue/bug open. Also it is important to always include a Fixes tag with tha hash that introduced the problem, specially in case of a crash since it might be a good idea to backport to fix.

Quoted 33 lines
---
 drivers/bluetooth/btmtk.c | 1 -
 drivers/bluetooth/btusb.c | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/btmtk.c +0 -1
index b7fc14aafc74..8a3f7c3fcfec 100644
@@ -1215,7 +1215,6 @@ static int btmtk_usb_isointf_init(struct hci_dev *hdev)
        struct sk_buff *skb;
        int err;
 
-       init_usb_anchor(&btmtk_data->isopkt_anchor);
        spin_lock_init(&btmtk_data->isorxlock);
 
        __set_mtk_intr_interface(hdev);
drivers/bluetooth/btusb.c +2 -1
index 9970470c9d15..15c0885c37cd 100644
@@ -2628,6 +2628,8 @@ static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
        struct btmtk_data *btmtk_data = hci_get_priv(data->hdev);
        int err;
 
+       init_usb_anchor(&btmtk_data->isopkt_anchor);
+
        err = usb_driver_claim_interface(&btusb_driver,
                                         btmtk_data->isopkt_intf, data);
        if (err < 0) {
--

2.18.0

Signature · 1 line
Luiz Augusto von Dentz
#2 lore raw

Hi Luiz,

Quoted 15 lines · Luiz Augusto von Dentz

External email : Please do not click links or open attachments until you have verified the sender or the content.
Hi Chris,

Quoted 8 lines · Chris Lu

MediaTek iso data anchor init should be move to where MediaTek claims iso data interface.
If there is an unexpected usb disconnect during setup flow, it will cause a NULL pointer crash issue when releasing iso anchor since the anchor wan't been init yet. Adjust the position to do iso data anchor init.

Quoted 8 lines
Quoted 1 line

Please add the backtrace or a Link tag if there is an issue/bug open. Also it is important to always include a Fixes tag with tha hash that introduced the problem, specially in case of a crash since it might be
a good idea to backport to fix.

Sorry about that, I will make sure to include those information if MediaTek fixes such Kernel crash issue in the future.

I've submitted v2 to add backtrace and Fixes tag information to commit message. BTW, I also moved the position to do anchro init to the end of same function in v2 which will make the flow more make sense.

Thanks a lot,
Chris Lu

Quoted 40 lines

drivers/bluetooth/btmtk.c static int btmtk_usb_isointf_init(struct

Quoted 10 lines
---
 drivers/bluetooth/btmtk.c | 1 -
 drivers/bluetooth/btusb.c | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/btmtk.c +0 -0
index b7fc14aafc74..8a3f7c3fcfec 100644
@@ -1215,7 +1215,6 @@ static int btmtk_usb_isointf_init(struct

hci_dev *hdev)

drivers/bluetooth/btusb.c static void btusb_mtk_claim_iso_intf(struct

Quoted 12 lines
drivers/bluetooth/btmtk.c +0 -1
        struct sk_buff *skb;
        int err;
 
-       init_usb_anchor(&btmtk_data->isopkt_anchor);
        spin_lock_init(&btmtk_data->isorxlock);
 
        __set_mtk_intr_interface(hdev);
drivers/bluetooth/btusb.c +0 -0
index 9970470c9d15..15c0885c37cd 100644
@@ -2628,6 +2628,8 @@ static void btusb_mtk_claim_iso_intf(struct

btusb_data *data)

drivers/bluetooth/btusb.c static void btusb_mtk_claim_iso_intf(struct btusb_data *data)

Quoted 7 lines
drivers/bluetooth/btusb.c +2 -0
        struct btmtk_data *btmtk_data = hci_get_priv(data->hdev);
        int err;
 
+       init_usb_anchor(&btmtk_data->isopkt_anchor);
+
        err = usb_driver_claim_interface(&btusb_driver,
                                         btmtk_data->isopkt_intf,

data);

Quoted 4 lines
drivers/bluetooth/btusb.c +0 -1
        if (err < 0) {
--

2.18.0

Signature · 1 line
Luiz Augusto von Dentz