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 DDF7E42B738; Tue, 16 Jun 2026 15:14:49 +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=1781622890; cv=none; b=nePkVmmgFN98kH2/7y/O+wA0gtQc/S0DLltVjhObTncv9Hmqa4kYVFbeC4ujGfz7I2fCnWhaSK8KWd75PM3w2Zc7snxN5wGOaL6TH2/oK+phOivfJ6XmQnLnhGerQNQYVhY4WFF6Y44NQorpxoJKDKl7gA2EMWR/iyidDQBMG9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781622890; c=relaxed/simple; bh=3CtDenxy3CGipq+78qxWmWmVBZVJbtNqgn1TdlTegOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HPUTeg1xAQcgfAFllTHgnrwGEs9oH+a7l22pBGk66R+aOq9tKQt0jiPbRfv3zYpNpSdDc2GOPufZOnVdkv20k1DJAZqRanB7esQFcedKGL6iVm5dOE684sMdmh5UxEUe7yJWCqO2MYvFo74kPPlrLSm986uGYDhhj/qVW6zNMqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OriQcAoR; 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="OriQcAoR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA5A71F000E9; Tue, 16 Jun 2026 15:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781622889; bh=OZRV5LZH+TOM2XrPlgEMnJ66dPI3kIdWjr5yxoDknL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OriQcAoRykLMZO4ActsgyTxtMEcUALjKQ7a27AGsnZOJ0z3VFnc7yr6yk4zSjWciv pd50h5qSnfzmYyx1OwGPtEOugtrYD50DNbYPZNw2fil95R7n+mYLvBWjXtMIdc2XYm Pft49vmns8FQ0P671Xmc0ZDHiolVaw5HkCGSGUiU= 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 7.0 049/378] Bluetooth: fix memory leak in error path of hci_alloc_dev() Date: Tue, 16 Jun 2026 20:24:40 +0530 Message-ID: <20260616145112.502266196@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145109.744539446@linuxfoundation.org> References: <20260616145109.744539446@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 7.0-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 041ce9adc378ae..8957ce7c21b76c 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