Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3669859pxb; Mon, 24 Jan 2022 14:58:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyT4hJMxv65CBjitdLBGE9TQdzWrQKBNKXmwtqqLa4f0STVVuarW5xKWnehA5RmrppKsnyA X-Received: by 2002:a17:902:cec3:b0:14b:4d5c:dcf9 with SMTP id d3-20020a170902cec300b0014b4d5cdcf9mr6539900plg.89.1643064972454; Mon, 24 Jan 2022 14:56:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064972; cv=none; d=google.com; s=arc-20160816; b=Nh72FVEQqEzLU8llfG3KoLwSInrZKRWfB2/NjH5KRJEMSMPAHPFnXR/6qbhLbzpGu2 En8VGydPLxcFf4FKB+QXSlYyp3MsQTE5ZIKMuDzN8d0cJFJ+EZWpnpTIe2qyNLPg1Q4E 01PsNtkpTVgmIa27oKtMJoPAxBZEzCaQnHQ3hO8j33HvE/V1Dc+GrjjrxUvTtm40KLQD aPcUXx9cyu3Om0gFufH9753CJviqfzbqHu4DB6pcpoSKfG2lYCe46mq9++Esrg/mxLHq G06mHsMJW9fPQu1IVFcwwdY6LJClZHOrtOxC9gechmpGVXO9Oc0jn6x7GansAnHvPdHv L9PA== 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=VR1zsVoEXUQSDQuJqNdaMkt4/U+j9RjYhVitMmMH7hM=; b=lK6T+EmX2OnM6evh8rkj1FKLsk7hlr4ZcxK9zcB5w68k+xXokShVBsu1SdnWGDNZN7 VM6MoJaWY1/4oVmwqanyIlWbapA0b85iLxktmqb04Gcmwb2de191QIrz7qv2igd6rSkm ymvg/dMcKr4qetFNIx2bDSO9WXarlKwZnAOzhEAZU/YC+MI8IFLJ5Kc3M/RxBtqRFmSl WTby/XrSt1JAJa+xwLbNR6gssmRnGNGcqICSm8UtK7DNtrF0Ss31dUICxdL95ytG28+k 6i19PZy9hVLGdvgBW8aP+/2B0BNj4LOBHLDbpm4wwoVzSMFaw11kzdhk8APeDOTitBq0 p1Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qG3OFeHO; 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 b7si13604988pff.301.2022.01.24.14.56.00; Mon, 24 Jan 2022 14:56:12 -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=qG3OFeHO; 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 S1840194AbiAXWww (ORCPT + 99 others); Mon, 24 Jan 2022 17:52:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1452445AbiAXVsu (ORCPT ); Mon, 24 Jan 2022 16:48:50 -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 183F4C081197; Mon, 24 Jan 2022 12:32:56 -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 EE1B26153A; Mon, 24 Jan 2022 20:32:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D43F5C340E5; Mon, 24 Jan 2022 20:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056375; bh=bvRgmzztybuxgeiocEHbhGy+hF9oTXJZSdyxIsdtvhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qG3OFeHORoese6DMlw7khWFIT4h5SxVWwhwoSiUtwWJqmK+8eNS5/2aiV9YPXjMzc ABNtl4bocVxZS3tWnNtB9JsZUjokS9LJ+BYNakhomNtxLKh8RJ+afWACepNf6SitrA yK9Jc6SDYQIKrZRe3eFm7IFXbUOHpnzq0limcy1c= 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.15 462/846] Bluetooth: Fix removing adv when processing cmd complete Date: Mon, 24 Jan 2022 19:39:39 +0100 Message-Id: <20220124184116.918866562@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 50d1d62c15ec8..20e36126bbdae 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