From nobody Fri Dec 19 07:55:05 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17401C433FE for ; Wed, 19 Oct 2022 09:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232195AbiJSJCE (ORCPT ); Wed, 19 Oct 2022 05:02:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232306AbiJSI72 (ORCPT ); Wed, 19 Oct 2022 04:59:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD632316E; Wed, 19 Oct 2022 01:54:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6840C61840; Wed, 19 Oct 2022 08:52:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79C46C433D6; Wed, 19 Oct 2022 08:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169568; bh=rMXzGfT+AwXnfRT0f5JD55o8ci30M3mUQCL/5UtoNGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1JV272Bjd1wO+SEr9GEbyUjfVqiol4nCf3vZ/hIs3opzAAdCIhxvt+arZpP+/jWk Pd4DzzBZDcZyZsvazB9I2Qo3ueAS26/ghzUMhtBoqQ/d6QMyQ4sav2HfXJMyYTUCgh g0p+QDcg0ficca7rdMtFwuwT/n6kDaBzAk8dyoZM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Abhishek Pandit-Subedi , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.0 325/862] Bluetooth: Prevent double register of suspend Date: Wed, 19 Oct 2022 10:26:52 +0200 Message-Id: <20221019083304.385189903@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abhishek Pandit-Subedi [ Upstream commit 4b8af331bb4d4cc8bb91c284b11b98dd1e265185 ] Suspend notifier should only be registered and unregistered once per hdev. Simplify this by only registering during driver registration and simply exiting early when HCI_USER_CHANNEL is set. Reported-by: syzbot Fixes: 359ee4f834f5 (Bluetooth: Unregister suspend with userchannel) Signed-off-by: Abhishek Pandit-Subedi Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 4 ++++ net/bluetooth/hci_sock.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e6be18eb7fe6..6ae5aa5c0927 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2400,6 +2400,10 @@ static int hci_suspend_notifier(struct notifier_bloc= k *nb, unsigned long action, container_of(nb, struct hci_dev, suspend_notifier); int ret =3D 0; =20 + /* Userspace has full control of this device. Do nothing. */ + if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) + return NOTIFY_DONE; + if (action =3D=3D PM_SUSPEND_PREPARE) ret =3D hci_suspend_dev(hdev); else if (action =3D=3D PM_POST_SUSPEND) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 0d015d4a8e41..bd8358b44aa4 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -887,7 +887,6 @@ static int hci_sock_release(struct socket *sock) */ hci_dev_do_close(hdev); hci_dev_clear_flag(hdev, HCI_USER_CHANNEL); - hci_register_suspend_notifier(hdev); mgmt_index_added(hdev); } =20 @@ -1216,7 +1215,6 @@ static int hci_sock_bind(struct socket *sock, struct = sockaddr *addr, } =20 mgmt_index_removed(hdev); - hci_unregister_suspend_notifier(hdev); =20 err =3D hci_dev_open(hdev->id); if (err) { @@ -1231,7 +1229,6 @@ static int hci_sock_bind(struct socket *sock, struct = sockaddr *addr, err =3D 0; } else { hci_dev_clear_flag(hdev, HCI_USER_CHANNEL); - hci_register_suspend_notifier(hdev); mgmt_index_added(hdev); hci_dev_put(hdev); goto done; --=20 2.35.1