Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3637301pxb; Mon, 24 Jan 2022 14:06:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhK0/xBZp1gc3NRhzvs1JDZEC3a9Xo4rSWAnDv4NTucVr/y4Hm1/5y0zdOEf/yJifEND0J X-Received: by 2002:a17:902:c412:b0:14b:1a3f:7d0 with SMTP id k18-20020a170902c41200b0014b1a3f07d0mr15805453plk.142.1643061998975; Mon, 24 Jan 2022 14:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061998; cv=none; d=google.com; s=arc-20160816; b=CbGNvSagj6BMB4kgPy/dwWfI2dFVjs0dZLytxZVj6EDmt4psSn0r09/ef8sX7lqgxJ UVMUrcFFZ34U4G8KLOcYbeoBYeeeJ4/QyWQb7pZDVTqJBLB3m56MhQZdUHO9dYgUKXm6 uHG+QgNAEgsm3MTj3RGFdNgBKUlWqx9mD7qwtkQDEAg2lgRsoY2ZGK4yxYlx0/FnXNIQ Qj8laty3YfEYuU3RGrCJzRPf+1PwbGq6rKNam1H5zUpdODMO6tQRm6CuRZSoLQtRNEap lXqgH58QaoBWRE3CVFcVRkMgvkZFZkw8AGiQCbDoPqgkucEuLi8mWwm5ZbRft8rW7/99 J5Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Lm1Jkb7jcoEtaP2QyiJWfAPxroxbOTnwwnNzrhu9ewY=; b=kCXWZTHOPvMyoWZXzdsUI1lh5O1bEJ/kna03QmE4nWxWBMAbHoisMelFx0wwuFmobB tD3eIMdyqVJ0/aW+JwaAWWs/+gEc23S7a2UOEKb8AJQJPjKJ16RQ96LY70j5aNBj72um h/5nb2FOtmSCvGjUAkUdTlr09RfxUMQ9XF8JltsFkgbHOcHsFAZpFYXbpMbbk0lpbjaM 767sabO5bfTAB/F7LAeU6tmL9G5GdusWokMydCG97+DzvnJu0sPd8dvW+PJjS1PZyxiH e96bLVw0eunVHL1uk3ezodEf9PwUCkZL2HWjkZvgKwbwgLGH+mK8QTZ9sSrQ17U0sK83 maSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m9A+tYIR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si14525503pfu.240.2022.01.24.14.06.26; Mon, 24 Jan 2022 14:06:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m9A+tYIR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575777AbiAXVwa (ORCPT + 99 others); Mon, 24 Jan 2022 16:52:30 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:37676 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1450398AbiAXVU1 (ORCPT ); Mon, 24 Jan 2022 16:20:27 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 9D2C9B81057; Mon, 24 Jan 2022 21:20:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFC27C340E4; Mon, 24 Jan 2022 21:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059224; bh=dlPDKHqCSXfPjaKZ96hJwLoit81JvMZoIoPBWl/uRsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m9A+tYIRIcKLlYBxb3oYISv8eRyqaDPH8/Yfp1bn/3hmYhU4DvSsrlOVZwc3qR82U ByuA5FM8xlaetEGIU7Erbr/BTqJMbjkYs3r/zr1Ei3sn5to3dza3Yg2ZCcMw95BTAN ilfK1iHaaXNnVxxbCVbuJefU9qdeyu7D5xmA3PvA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Archie Pusaka , Sonny Sasaka , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.16 0543/1039] Bluetooth: Fix removing adv when processing cmd complete Date: Mon, 24 Jan 2022 19:38:52 +0100 Message-Id: <20220124184143.528865585@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 6eba439487749..8882c6dfb48f4 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 */ -- 2.34.1