From: <sean.wang@mediatek.com>
To: <nbd@nbd.name>, <lorenzo.bianconi@redhat.com>
Cc: <sean.wang@mediatek.com>, <Soul.Huang@mediatek.com>,
<Leon.Yen@mediatek.com>, <Eric-SY.Chang@mediatek.com>,
<Deren.Wu@mediatek.com>, <km.lin@mediatek.com>,
<robin.chiu@mediatek.com>, <Eddie.Chen@mediatek.com>,
<jsiuda@google.com>, <frankgor@google.com>, <kuabhs@google.com>,
<druth@google.com>, <abhishekpandit@google.com>,
<shawnku@google.com>, <linux-wireless@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>
Subject: [PATCH] Bluetooth: btusb: medaitek: fix double free of skb in coredump
Date: Sat, 3 Feb 2024 07:55:27 +0800 [thread overview]
Message-ID: <ca2b3447d110874d90e93c6ddf972f4ad2bc70f9.1706917839.git.objelf@gmail.com> (raw)
From: Sean Wang <sean.wang@mediatek.com>
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: 0b7015132878 ("Bluetooth: btusb: mediatek: add MediaTek devcoredump support")
Reported-by : Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
drivers/bluetooth/btmtk.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index aaabb732082c..e882613036a0 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -378,8 +378,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 */
@@ -405,9 +407,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);
--
2.25.1
next reply other threads:[~2024-02-02 23:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 23:55 sean.wang [this message]
2024-02-05 8:37 ` [PATCH] Bluetooth: btusb: medaitek: fix double free of skb in coredump Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ca2b3447d110874d90e93c6ddf972f4ad2bc70f9.1706917839.git.objelf@gmail.com \
--to=sean.wang@mediatek.com \
--cc=Deren.Wu@mediatek.com \
--cc=Eddie.Chen@mediatek.com \
--cc=Eric-SY.Chang@mediatek.com \
--cc=Leon.Yen@mediatek.com \
--cc=Soul.Huang@mediatek.com \
--cc=abhishekpandit@google.com \
--cc=druth@google.com \
--cc=frankgor@google.com \
--cc=jsiuda@google.com \
--cc=km.lin@mediatek.com \
--cc=kuabhs@google.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=robin.chiu@mediatek.com \
--cc=shawnku@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.