From nobody Mon Jun 8 07:23:00 2026 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF4ED22D4C3 for ; Sun, 31 May 2026 18:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780253641; cv=none; b=dhX7ADdjbqrouPmhyXW8rKY5v83Eq2hRoPPiXJFXhTFjJyy3VSpAEvXsypsiLB1NQp+fAktXAIWdTq4GBtKyKA0w0jZnzVXIvrjPL4qikvUzBUeYwy6U+tSU27YKH/9zOX2J0lARDYTTaVJzb8U6yJAVrF51ryaUMck9RUd9+Is= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780253641; c=relaxed/simple; bh=tlVMrBxRS+UJLeASwMVg94vHLb/S8hmVDe1PiOuwpnI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IafnWEj18kK41xJNfyY4piicz9AH6U9yrqPXdjYhPgiVuFPEKg/2HPLcDMclMLeCbFJfRoi8iP1To2GuPt8H14ALak0BLHGKdvuYJz6OHwbIlZr0yK/huMYIzC01iiMoAycjEy5P8ff3R+gSHamQFrEc14CjVle7/oaS8Lpy9fw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hO3nQjZv; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hO3nQjZv" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-36d5fd50d20so913796a91.1 for ; Sun, 31 May 2026 11:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780253639; x=1780858439; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yCfnDp4TVil5GLFtV2CJjvE4FzB7iM9xNBhhS1ttWQs=; b=hO3nQjZvbcLcGpz2b73SVTnAw1aFawAdjyNvCVrgFb2O2rJCVmsPaipbeeTjhUCSGZ UQVI+3eOGeaEh+hk3j7e2lPyaf4N0Wep/CSMaEoKVrlXy+avmh/wKZQjlQBmnjPlHQJ9 9KKaRUzIxYm0cZFiN0wwuiSCfTEg7VyznoKNpIu6ez+R9k33yxMlzpNR1JF7qWCYWG2f ePa8Ogkq8GzhaVmYS0MmjGCpcoD27akcdisqpmp8nZWwrifgRSgu+52Eadcmn18l28St Fydl3OB4rMbu4aqglrRNCOcfg7sgjkPlyWZs7NoLE7bCPIvaYM7Snk5Imr1xJSuO9gzy vRrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780253639; x=1780858439; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yCfnDp4TVil5GLFtV2CJjvE4FzB7iM9xNBhhS1ttWQs=; b=XpwoeBYu9uaLDo5kYdwGLsZk/G35eWWblXysAkql7grs1n4+nH0YSUyGngHtzSlFw+ FZ7sg0TWG/1iBi1kTts8ObmkHgpTwJs1gNtElrLKF7tGf4N0zFlezFP4m2pzuAd/nsxO 4VVGBh6ph7TUV8sYUXaGkz6qtqJwvExzXpzLYLafqYdX+bR4UEG7tjW5Nq/8+6Vf7wx1 /H0CRcHIvBMrnEvQiKmvmcBtZVdoR6hEBivngBCQduhmTmuStUUmhF+k3dCwiY0t2ndo d1WTh8sfLXe0IDl1gDyl9uNg4AZM5VezbyTgJRkB0n6xB6HLH9TIloWPmCp4Z5lpDMl7 b0WQ== X-Forwarded-Encrypted: i=1; AFNElJ8cMNyKCArdmM0ryyMmSh9WbT4gTgmqYxuNYvV7ZV7u0vYOJbGGomStyK1MD+ZNtiRq3+jjbCSYPBN88M0=@vger.kernel.org X-Gm-Message-State: AOJu0YwsGenNojo73GPQmJm1rPsYHKHo/c52w+kmNUjn3T1+d7PZ8cGr hh4ekE0Mcauf49uswyu90WR0anXQ6+FpMLSUs1KZgYOEeBX7LpmHWaN0RnOkg9XnXtA= X-Gm-Gg: Acq92OF1ZIIMehjjYmjl5f7QsO3eUrc+Iq+s2karoQLKhiw0nE26aQHm4SavWEK1ZRX vhlQIYr9CH2goLwigCUgW6+jOU0kZWtevt2PvvTrPLhI6/ZFKuM3rFgS2CsnoS1bcRYbLXLrB53 s/Bc/tTiXOFvt0F+PEbjnhbIssGyahF2f/BmWtLGNuHd5rAdTecP7u38XxO+EC4aZdjGvdhSgGm 8bk1oSEeOlCaQTxYJcdjIrUjMaf4QByjfCBW1ih2cZuGpEQWcPZZHwNXfmax4lqLFnlUWe7Zj7Q lDMxwrN0JdWxbo2/ije2xpcVzeLDyY7b30JD+vErnUTPWhIfWY8aU8Vs59+g2eXPEcQUxFM7/GY U/rjw5KrfhVk0qztyfUtdVY6cgvJ/CMXz6ll0vFrYqVfK/C14szsq3HLiamhm/+Gz9fSsECFTZc gomD4PInb/18dmjfxaqO76eL9jm6/v/GQtyZxGhVz/Z+rgLD0ms6o8iNTrSdHrzE0dJpwe9u/r3 VkkNQHvmPsnLgQkoAL42/rTGMaaYQ== X-Received: by 2002:a17:90b:35c2:b0:36b:8873:d96d with SMTP id 98e67ed59e1d1-36c4ff65291mr7107251a91.11.1780253638891; Sun, 31 May 2026 11:53:58 -0700 (PDT) Received: from rustle-HP-Pavilion-Laptop-14-dv2xxx.. ([49.205.241.70]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36d654999a0sm5839594a91.0.2026.05.31.11.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2026 11:53:58 -0700 (PDT) From: Bharath Reddy To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Bharath Reddy , syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com Subject: [PATCH v4] Bluetooth: fix memory leak in error path of hci_alloc_dev() Date: Mon, 1 Jun 2026 00:23:39 +0530 Message-Id: <20260531185339.107188-1-kbreddy.rpbc@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D535ecc844591e50588a5 Tested-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com Fixes: 1d6123102e9f ("Bluetooth: hci_core: Fix use-after-free in vhci_flush= ()") Signed-off-by: Bharath Reddy --- Changes in v4: - Include patch version history. Changes in v3: - Added missing curly braces to the if/else block in bt_host_release()=20 to resolve a checkpatch.pl warning. - Added Fixes and Closes tags. Changes in v2: - Fixed a NULL pointer dereference caused by v1.=20 - Moved cleanup_srcu_struct() to the fallback (unregistered) branch=20 of bt_host_release() instead of unconditionally calling hci_release_dev(= ). Changes in v1: - Initial patch (failed because it bypassed the HCI_UNREGISTER check). 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 041ce9adc378..8957ce7c21b7 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 =3D to_hci_dev(dev); =20 - 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); } =20 --=20 2.34.1