Skip to content

Commit

Permalink
Bluetooth: btusb: mediatek: Fix double free of skb in coredump
Browse files Browse the repository at this point in the history
[ Upstream commit 18bdb38 ]

hci_devcd_append() would free the skb on error so the caller don't
have to free it again otherwise it would cause the double free of skb.

Fixes: 0b70151 ("Bluetooth: btusb: mediatek: add MediaTek devcoredump support")
Reported-by : Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
moore-bros authored and gregkh committed May 2, 2024
1 parent 882d614 commit 80dfef1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/bluetooth/btmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,10 @@ int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb)
switch (data->cd_info.state) {
case HCI_DEVCOREDUMP_IDLE:
err = hci_devcd_init(hdev, MTK_COREDUMP_SIZE);
if (err < 0)
if (err < 0) {
kfree_skb(skb);
break;
}
data->cd_info.cnt = 0;

/* It is supposed coredump can be done within 5 seconds */
Expand All @@ -407,9 +409,6 @@ int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb)
break;
}

if (err < 0)
kfree_skb(skb);

return err;
}
EXPORT_SYMBOL_GPL(btmtk_process_coredump);
Expand Down

0 comments on commit 80dfef1

Please sign in to comment.