From mboxrd@z Thu Jan 1 00:00:00 1970 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 3670933AD9B; Tue, 16 Jun 2026 16:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781629180; cv=none; b=AGueuwfV5exGVnJmi/rK13p4IRne+6J5GKSg3xeumlEzNhhAEjQyBCQyYHmbgpYRNi+ngO2G3rCl7f70zbZK3Dyey3WWJcuFDbS9VmbDCx4MMTu1fJg2Gq6fgVqEFn+jzNK8//J8ox5ArrfiuuS4dekvfn9RfIfQR2oRG27NcJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781629180; c=relaxed/simple; bh=miUVu2qrVOwne7Xm/BaAH1XLmgEn8pVgc5TztglyGO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IQdht9Kedxgfg5me2hwv2e6ZXbiwjf3v1yrRZrkmm4oVFv/WZFAC0LY4eI6R0EYO8e+39F1VKds0kMvK2wRqpGTNuvSLhP800si6be1PTzJK1XcaE3u6lnd9vLPBts2RugEydeeNQ57puVHpqiBCBSCEFt791xZaqJU6xnaNQPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dHHS+4T1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dHHS+4T1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E38361F00A3A; Tue, 16 Jun 2026 16:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781629178; bh=/q6IJTGufDdHFB1oXC2xYiUxL6DkFvTp+IL2lZnECPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dHHS+4T1n+eEEfYciWKg99kgImnRgh5qvWdRmcH4F/NvxM0H7Gezk+wrgN5BbnKPD RYRRrQ3PkPZ/rauKXy6CZScDlBPiJ4+LkplrBcve74fxMrnCxvJsgvY4f4oParL0sS Pm/M+Ni5SvksHgCTCkSgintlm5cheJXk07XhJ7AE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com, Bharath Reddy , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 236/452] Bluetooth: fix memory leak in error path of hci_alloc_dev() Date: Tue, 16 Jun 2026 20:27:43 +0530 Message-ID: <20260616145130.090307062@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bharath Reddy [ Upstream commit 37b3009bf5976e8ab77c8b9a9bc3bbd7ff49e37f ] Early failures in Bluetooth HCI UART configuration leak SRCU percpu memory. When device initialization fails before hci_register_dev() completes, the HCI_UNREGISTER flag is never set. As a result, when the device reference count reaches zero, bt_host_release() evaluates this flag as false and falls back to a direct kfree(hdev). Because hci_release_dev() is bypassed, the SRCU struct initialized early in hci_alloc_dev() is never cleaned up, resulting in a leak of percpu memory. Fix the leak by explicitly calling cleanup_srcu_struct() in the fallback (unregistered) branch of bt_host_release() before freeing the device. Reported-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=535ecc844591e50588a5 Tested-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com Fixes: 1d6123102e9f ("Bluetooth: hci_core: Fix use-after-free in vhci_flush()") Signed-off-by: Bharath Reddy Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_sysfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 4b54dbbf0729a3..60350c6723cb76 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -83,10 +83,12 @@ static void bt_host_release(struct device *dev) { struct hci_dev *hdev = to_hci_dev(dev); - if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) + if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) { hci_release_dev(hdev); - else + } else { + cleanup_srcu_struct(&hdev->srcu); kfree(hdev); + } module_put(THIS_MODULE); } -- 2.53.0