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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FE1BC433F5 for ; Fri, 29 Oct 2021 08:33:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CEFF61179 for ; Fri, 29 Oct 2021 08:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232498AbhJ2Ifu convert rfc822-to-8bit (ORCPT ); Fri, 29 Oct 2021 04:35:50 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:53737 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbhJ2Ift (ORCPT ); Fri, 29 Oct 2021 04:35:49 -0400 Received: from smtpclient.apple (p4ff9fd51.dip0.t-ipconnect.de [79.249.253.81]) by mail.holtmann.org (Postfix) with ESMTPSA id E64A9CED10; Fri, 29 Oct 2021 10:33:19 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.20.0.1.32\)) Subject: Re: [PATCH] Bluetooth: Fix removing adv when processing cmd complete From: Marcel Holtmann In-Reply-To: Date: Fri, 29 Oct 2021 10:33:19 +0200 Cc: Archie Pusaka , linux-bluetooth , CrosBT Upstreaming , Archie Pusaka , Sonny Sasaka , "David S. Miller" , Jakub Kicinski , Johan Hedberg , Linux Kernel Mailing List , "open list:NETWORKING [GENERAL]" Content-Transfer-Encoding: 8BIT Message-Id: References: <20211028191723.1.I94a358fc5abdb596412a2e22dd2b73b71f56fa82@changeid> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3693.20.0.1.32) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Luiz, >> 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 >> >> --- >> >> 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 3cba2bbefcd6..894670419a27 100644 >> --- a/net/bluetooth/hci_event.c >> +++ b/net/bluetooth/hci_event.c >> @@ -1326,8 +1326,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 >> */ I haven’t applied this yet since I wanted to make sure it doesn’t interfere with our set of 23 patches. Do you need to rebase? Regards Marcel