Article View: linux.kernel.netdev
Article #1117[PATCH] Bluetooth: btmtk: fix skb double free on ISO padding failure
From: Eric Dumazet
Date: Fri, 09 Oct 2026 08:35
Date: Fri, 09 Oct 2026 08:35
45 lines
6564 bytes
6564 bytes
btmtk_isopkt_pad() uses skb_pad(), which frees the skb on failure.
The error is propagated by alloc_mtk_intr_urb() and
btusb_send_frame_mtk() up to hci_send_frame(), which frees
the skb a second time:
err = hdev->send(hdev, skb);
if (err < 0) {
bt_dev_err(hdev, "sending frame failed (%d)", err);
kfree_skb(skb);
return err;
}
Use __skb_put_padto(skb, MTK_ISO_THRESHOLD, false) so that the skb
is left to the caller on error. This also replaces the open-coded
skb_pad() + __skb_put() sequence.
Fixes: ceac1cb0259d ("Bluetooth: btusb: mediatek: add ISO data transmission functions")
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
drivers/bluetooth/btmtk.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 7ea8bcd8a7ecaa0122d96cc3787307301401e00f..c9175d478a9845bd476ad998815429d2748b78f2 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -1023,12 +1023,8 @@ static int btmtk_isopkt_pad(struct hci_dev *hdev, struct sk_buff *skb)
if (skb->len > MTK_ISO_THRESHOLD)
return -EINVAL;
- if (skb_pad(skb, MTK_ISO_THRESHOLD - skb->len))
- return -ENOMEM;
-
- __skb_put(skb, MTK_ISO_THRESHOLD - skb->len);
-
- return 0;
+ /* On error, the skb is freed by hci_send_frame(). */
+ return __skb_put_padto(skb, MTK_ISO_THRESHOLD, false);
}
static int __set_mtk_intr_interface(struct hci_dev *hdev)
--
2.53.0
Technical Details
Message-ID:
<20261009083525.733804-1-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343516-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343516-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH] Bluetooth: btmtk: fix skb double free on ISO padding failure Date: Fri, 9 Oct 2026 10:35:25 +0200 Organization: Usenet Network Message-ID: <20261009083525.733804-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1064835"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:xqUQ2NTJOdnU+N+EmSjE0j3a7lo= sha256:3KQKcQuVVtDHcDNSQH5OnUb+OMReftTs7k6MdzjPN+g= sha1:ujIwggeqpVk3/j4b6NHfAvhsisg= sha256:4DTlhfq/qjZVAgLwJjPOlHPTVwAoRwzQJ7lDGsaJY+8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CE87710F60D; Fri, 9 Oct 2026 11:39:09 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.541 X-Spam-Status: No, score=-2.541 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qNvcb0dVwobE; Fri, 9 Oct 2026 11:39:07 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-343516-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id A1B3210F5FF; Fri, 9 Oct 2026 11:39:00 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 395523CA74; Fri, 9 Oct 2026 08:35:33 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B4DD3E9F76; Fri, 9 Oct 2026 08:35:32 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YuNU5hOi" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D9643D7D65; Fri, 9 Oct 2026 08:35:30 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791534932; cv=none; b=s8aQyXDkFV1SiuO23IC7lfpXzlqF1BPV3vehza1KKDPidAnkAff3vV9PcDyHQqhL0oxP0HJdJccxuXAUbCjPgJoDZ06rn7ivDEYCrKkFEUFbDBIcoUUcAL6erPtM7iKxZC3RJ5rH9s/o7/etJK7E0ccza2vy9DOcNw2RiQMZQQ0= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791534932; c=relaxed/simple; bh=BXlxO+lNnI/IhYwqOpuyxA8euR2MK8wX3hu7K+gwHRo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iAanLkAcJ/8n7KubYaVZIj4Ggu1iLuKy+n+qmS/V02Ps8sqMqzGmKQEjhiHdXFFTLDw/d9CJaPjBPuKsZJ0HzZyCPTeQdkk/cV7kYXjExHp+A/uyFmvrIkTwYS6t7ZRxPiQq1/SCFhzboObiAYxKeeLVEZlNA5kGB8m/+USNFYo= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YuNU5hOi; arc=none smtp.client-ip=100.103.45.18 X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A51391F000FF; Fri, 9 Oct 2026 08:35:28 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791534930; bh=NhVNrMJ9T8caGDwFa9qT4qr4Wo3dvsNS2VTvf9SdOKw=; h=From:To:Cc:Subject:Date; b=YuNU5hOisl3DkKZTcnRGmrnKyaoTJ3WtllGmW6dOQpwsuxzknafS937gdt8JgBeoz fxfZ7dZ0jl6EvQXukvUazYQIOBxoV1nvVbAzTkoxglqdQkFa7OntjDjIGlVdzHsOcB VccBZTJMetnNDNJoZXxqbuYdIFrXq7hFsyE/jWYY1c42kEk4+SIkTgih0kKGthkeKI HBrDLwj/9t0eOb7XpuuICDyWi9kekYutkLfN6uS9TDwixBGbAcwLjPvulv6Gr0g1++ bEZBsz7luialcj92HBq2Gh11D+geV11wHEu5nz1jAyq0cYERbbpOEMGzRwN6CKj+1z SzLIlLwZKTZ8w== X-Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Eric Dumazet <edumazet@kernel.org> X-Mailer: git-send-email 2.53.0 X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>