From mboxrd@z Thu Jan 1 00:00:00 1970 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 70DF9C4332F for ; Tue, 18 Jan 2022 02:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344757AbiARChW (ORCPT ); Mon, 17 Jan 2022 21:37:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245674AbiARCc4 (ORCPT ); Mon, 17 Jan 2022 21:32:56 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBAF0C06175D; Mon, 17 Jan 2022 18:32:02 -0800 (PST) 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 2664F611FD; Tue, 18 Jan 2022 02:32:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54B3BC36AE3; Tue, 18 Jan 2022 02:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642473121; bh=y7DUbAYnbV+W1Whx7ceW4ohwB+O7PWFAmZ3Y6eWH30c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a87Za1gQm8V86lQeLTM/To8U7s4gblrwavBKUxafxC+qUwwwOJHYtV/hWuceC6YeF CWjL9yupCc05JYxx951ZmMtE4Ff1G3ytEE5jGGdG2fCRy8Bss5Aa1youGj0YMfJgg/ 49ioELjlXTbZNk9RgaNQH5kOZCk0jjcNwd/E7fvG4NfW1teM2GqxrS2nZmBSg8Aa2Q TzuIvl6M9Is0glrCkiBJYxT037GS5Mm6N25kutnhCJfPrRtl74m5f7gM4/kK8BxbED 9MFqIbqewKuOb3DtqML8LW1cqPHqbOnjmIwwI3/dAoJnewDhXxzFTchJg8nEONeIjU 9ZeOQilKLUocQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Archie Pusaka , Sonny Sasaka , Luiz Augusto von Dentz , Sasha Levin , marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, kuba@kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 004/188] Bluetooth: Fix removing adv when processing cmd complete Date: Mon, 17 Jan 2022 21:28:48 -0500 Message-Id: <20220118023152.1948105-4-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118023152.1948105-1-sashal@kernel.org> References: <20220118023152.1948105-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Archie Pusaka [ Upstream commit 2128939fe2e771645dd88e1938c27fdf96bd1cd0 ] If we remove one instance of adv using Set Extended Adv Enable, there is a possibility of issue occurs when processing the Command Complete event. Especially, the adv_info might not be found since we already remove it in hci_req_clear_adv_instance() -> hci_remove_adv_instance(). If that's the case, we will mistakenly proceed to remove all adv instances instead of just one single instance. This patch fixes the issue by checking the content of the HCI command instead of checking whether the adv_info is found. Signed-off-by: Archie Pusaka Reviewed-by: Sonny Sasaka Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_event.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0bca035bf2dcc..75116cf1b173d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1325,8 +1325,10 @@ static void hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, &conn->le_conn_timeout, conn->conn_timeout); } else { - if (adv) { - adv->enabled = false; + if (cp->num_of_sets) { + if (adv) + adv->enabled = false; + /* If just one instance was disabled check if there are * any other instance enabled before clearing HCI_LE_ADV */ -- 2.34.1