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 2A57844B68E; Tue, 16 Jun 2026 15:51:54 +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=1781625116; cv=none; b=oJ6kWLfRNg7jM6cQDDhtsXprvKDA5XPdwchZz04DKoxogBed8gT1qzZAiJ8dn9V+IGRWaT+f2xLAhn2q2lABfLcMnXSYCl2TGMxwUjwzxrGTIA4Lj3WNQvwtFGareauiuuDuRVQWb+1jwKDSx2L2zm/gHMNOwYWAgO6zp2eLz+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781625116; c=relaxed/simple; bh=I8rOrhnjkPX3AY6VOXnpqi8wYmQI7O7FOsZjPS2ke0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LiWNC3KIGMX595ddSAZIJwa0JKCuFiwciD071D0pjm+eK+5Q/mHOmfjwM48J6YEGfdv0zLu+4Zikvlz2cNVimMdEChzlgV6gtAAk+rMi+ikeAo9cmEnRTjGZ8mZmKQIWRqksHEgr+2eDf7Pk7Q+grQHCbntb5wIB/YGvXxNq9OU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dDeUhuZF; 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="dDeUhuZF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ACAE1F000E9; Tue, 16 Jun 2026 15:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781625114; bh=PgYK7xYrvxmoi8xKjTdoXfXJXUvBnFeG8LhyePzn+74=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dDeUhuZF/xHbcqJWM95wxBGdWT1evd4M9A+JAe2m+ntQTGrrX5QlsxBmg3Zq8Ty0U 1tTRdSipQP9K1iskj1bG5+nipzPvvC+u0owKIMvNmVcwEufKxm/OxgdV4+HTH9/xxJ kEqBgsA98dBAFEsMjTw2Uxb53aEDZm0al6HfZFps= 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.18 047/325] Bluetooth: fix memory leak in error path of hci_alloc_dev() Date: Tue, 16 Jun 2026 20:27:23 +0530 Message-ID: <20260616145100.073290028@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145057.827196531@linuxfoundation.org> References: <20260616145057.827196531@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.18-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