From nobody Mon Jun 8 07:23:00 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 AAC04362156 for ; Sun, 31 May 2026 14:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780238502; cv=none; b=DMToQwKnz3VO71nIXHncPcNtr2lbwlikcczstpa47Y5MQ1mabLDofCOwkkwolZijPoj7hQbHCXEXWXmCd6+VEs1RWrX8LySIC7/vUpje9vtv0kgPheGw3Lif/gRn8ZuK+g4tSvoyGhM24ivtbbDcOpvRe8Ws1+I+Xl3IhRvKQ/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780238502; c=relaxed/simple; bh=Ltn11O9vX1aG/w0uwy9Jh5ODIlkQjM7y7tTppaF6n30=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZxgiCiTFDhOYMQHnbFLCxQT+u129Q6p9JUOdFksZnSOM7PfY8WvjKQqxmStb6G8shz6labb2t2g1QXVJMUfmr2vodNPDp/1gqqoD4hFLFdxkMhe6/NTZPCNlGgnW/wR8S2DP8bM1YeVJ4E6Ym79yAOHMBJwZkJm903eDiszOCpY= 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=FD1IwFaM; arc=none smtp.client-ip=209.85.214.177 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="FD1IwFaM" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2c0c3543590so3209575ad.2 for ; Sun, 31 May 2026 07:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780238496; x=1780843296; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L55U4/GyMMLvrAhU/wt5YQLuRqzV5KrMItfh+6YXwhc=; b=FD1IwFaMy4lMY+mSqLmJNNHRk5tx6Zri5Jbc24Py5AupafKXVWvqVL4gcKr4bROyH8 K3TG8ZL/uTcpmjlw4TMmIrFZBT7A95OtRF2D2V13vACazO6Rt4HqdMuN0vfrQqySQEva RPJbO5OXQcsYghsOwwZSDIA1qxa8O7RbAJ56hxnWMYz+G2QMQvmQykPmN5+7lH1ogYF4 zRItJVQ0+lJ1IowT42m2wwT7A3XI0MNfrElZSg0bqr6g3894HK76ItbGyGJytv65Uy2v zEIiwdV01H5c5QAbfePUp0nXoKvJT0zIbz+jDdhhrFXhiAq90vvhAdrR3lDom+X8C5XT aFIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780238496; x=1780843296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=L55U4/GyMMLvrAhU/wt5YQLuRqzV5KrMItfh+6YXwhc=; b=YFpV/uzJ8Nue3HrOo0Px20mlx0vgRnRf7/vcOkfBYw4KZzDC1PQ7RzYLysJI6qXbAQ vQG87aA1h9Yh+OUcOJB7f5skUtptCT/JE+W5H+PUKqPsNDhmTV12qMT6FDCKx7nNqP1b wa3DWKkVe5GjL4CRrcZWhZk3Uhg4KZ/F4ITv8A6BC8/9FQI5mtJJZzttpqrxX2sfa2mp GmeUe2w0ICqXdTrBLg/2FsoXOeEFIaP6nyRCVy/VJLwfp2jYsKbh1BhS17AAyHDW1XwA Np9thUOR5iTBj4vuTqe1Ee9Uq2MelUMuU/EAQE4B2HHb5XUk1Xy6AJRpmhzE0nfNbbMu 4lVw== X-Forwarded-Encrypted: i=1; AFNElJ8aFWpOgq6XingnE5qY8eCnU9wTNNQl8CFo4sA05aX3kma3YuTdq3dSC3XXaHa/gQRPJf4trGNKr53jIhA=@vger.kernel.org X-Gm-Message-State: AOJu0YxahalUMS0GuvOHJbDTnhSqB7DpmDgbh7NScEmbQ+7H+0qKAXNb 4S89PzZ5FH8oBU1Xeb7XG8CrXqwrlHg8momZCn7ZkT1fMGpOyI+mY59B X-Gm-Gg: Acq92OEYhHjVtI3LygesK3fAh7KwUb0pkD0q+h5xtS7ZbkH88SfcuZzavXxjUvR4vjF VDTUDSFoHugV3UxHq2VG7lJMjj5Km+1Om9qTzTxS3IJHLxaszURt8RuOVz3JRSAHgpf2YRoz5zX fAOM49+5K4veCWBTW5uyE75VY6K1Bg5fEBPHPEKGuxyQVBgzmdypvPeU3cfRu54rhp1lzsS1WvL hWS9TtJ7T41Bg6eCQuAdzvtXvqjuKCmKHctPnQSTk34ZI0l4WpwiYruGVZJy9c8S+cGmzyJekFR 87QoHt/djZ/xuHXEtNSxMMPvaIE+kBDc/ku1QKqHjwo2ZKWXCRCsfHcRS5WiGP9dbEfJuDd/AaZ bWTBNM+4DJyfGtq3hpVfw9LuhuGjJaZ9i52h+WCKZDD87IZxj1SURRnlXPFRzS5Ha9Lmc7ugL98 OQJWc//T7AnegKZDHeAkKbyJuCmUppuzxCNIGjfZoLE9IXIaQLV1TS2ob621Fl/gCKtWGCWwkoj pCS5flzBiHQ6YizWafUIu9AkEorpw== X-Received: by 2002:a17:902:ecc6:b0:2c0:cb90:1e07 with SMTP id d9443c01a7336-2c0cb902145mr24221285ad.11.1780238496465; Sun, 31 May 2026 07:41:36 -0700 (PDT) Received: from rustle-HP-Pavilion-Laptop-14-dv2xxx.. ([49.205.241.70]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bf23b018b6sm79796945ad.43.2026.05.31.07.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2026 07:41:35 -0700 (PDT) From: Bharath Reddy To: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com Cc: kartikey406@gmail.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Bharath Reddy Subject: [PATCH] Bluetooth: fix memory leaks in error path of hci_alloc_dev() Date: Sun, 31 May 2026 20:11:17 +0530 Message-Id: <20260531144117.98430-1-kbreddy.rpbc@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <6a1b8c87.fbc46276.d3ed.0668.GAE@google.com> References: <6a1b8c87.fbc46276.d3ed.0668.GAE@google.com> 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" #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= f377d0025eb0 Syzbot caught a percpu memory leak in the SRCU struct when Bluetooth HCI UART configuration fails early. The problem boils down to a bypassed destructor. If device setup fails before hci_register_dev() completes, the HCI_UNREGISTER flag is never set. Later, when the device is freed, bt_host_release() sees this flag is missing, skips hci_release_dev(), and jumps straight to kfree(hdev). This leaks the SRCU memory, which was also incorrectly being cleaned up in hci_unregister_dev() which is also skipped during an early abort. To fix this and properly balance the allocation and teardown paths: 1. Move cleanup_srcu_struct() into hci_release_dev() so it directly mirrors the allocation in hci_alloc_dev(). 2. Unconditionally call hci_release_dev() from bt_host_release() by dropping the HCI_UNREGISTER check. This is safe for unregistered devices since it only cleans up resources initialized early on in hci_alloc_dev(). Reported-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com Signed-off-by: Bharath Reddy --- net/bluetooth/hci_core.c | 3 ++- net/bluetooth/hci_sysfs.c | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index c46c1236ebfa..f6bc7cb3e55c 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2701,7 +2701,6 @@ void hci_unregister_dev(struct hci_dev *hdev) write_unlock(&hci_dev_list_lock); =20 synchronize_srcu(&hdev->srcu); - cleanup_srcu_struct(&hdev->srcu); =20 disable_work_sync(&hdev->rx_work); disable_work_sync(&hdev->cmd_work); @@ -2774,6 +2773,8 @@ void hci_release_dev(struct hci_dev *hdev) kfree_skb(hdev->sent_cmd); kfree_skb(hdev->req_skb); kfree_skb(hdev->recv_event); + + cleanup_srcu_struct(&hdev->srcu); kfree(hdev); } EXPORT_SYMBOL(hci_release_dev); diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 041ce9adc378..261b28a25b02 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -83,10 +83,8 @@ 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)) - hci_release_dev(hdev); - else - kfree(hdev); + hci_release_dev(hdev); + module_put(THIS_MODULE); } =20 --=20 2.34.1