Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3383845pxb; Mon, 17 Jan 2022 19:13:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYPqHY6R79cOH6OSX7C/NjKbGso2weY6CUTZ9QNDy48FA7gHKE3Ad1mkwVezNvfQoHz8Wh X-Received: by 2002:a17:902:e98b:b0:14a:3d97:e678 with SMTP id f11-20020a170902e98b00b0014a3d97e678mr25373751plb.40.1642475589873; Mon, 17 Jan 2022 19:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475589; cv=none; d=google.com; s=arc-20160816; b=vhQl4m67gKb7WMx+s3vtTZgPX00pVzMQSnmubGeubJ75oha46UDQxkyGeUTVx/Hd5W kbhrsskTBC4yxcmDoYNROE5Hdi81UZXh2SxWvhOOpDtpO+SXsssSFUm5uwfgk7zuUjEZ VBjO0FO4QSk+r/HlHwRMD+nBfdC3R1itEjhhrINfvyVRgC1Uf/sE8AnE14IypX5qwdci FT5wWVWuV767kQGYP0ZhAFdV2MZ6PHMn8/xEwMK6hJ0lfseq4Oojewi+UsoSslwwJ9xF u4i8SgIrJZhhGlCa3tUnhQvN78N0ayHfUSxYyZhGodY9k9GwGY9n3MFgRf2Das9VT4A+ C/7w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BhBjTBDY3frCje3fWqZxIosBUxLbGAELEc+ZCvWx3P4=; b=cmEZWvcGBsVRMH8h9/MMh70pHuuVUGfSVcMxNWoT2v9OixeD2Vqy+lwP4AD1mxHh5m fdMFH1MmC7uaztHPj1mx2ZEqGjBT8UwoXGn0WlKAsj581MArj9mwaDfsxdT+/f9Z/GWl 4c1quQI48uHjBM2v5XkO/xPj+MTFniQxmSi4nV1uVMGhS3DYnyLZMCxJmgl1AaCyE7Ua KFzAs5Ds8nx0a7TqBvwjiIZ79noWLmReZIqfRpS8OIDm3LEzGhRLm9az9bwdnAtVAe2B lFEOBc87nwCtuek1tNzXftRANqa4PPvWMGi5b2JOaJmmam4eYvXDzNAC88VB3P91UWpq nskg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fCWdC8Io; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si17591620plh.451.2022.01.17.19.12.57; Mon, 17 Jan 2022 19:13:09 -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=@kernel.org header.s=k20201202 header.b=fCWdC8Io; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244458AbiARCUE (ORCPT + 99 others); Mon, 17 Jan 2022 21:20:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244359AbiARCTv (ORCPT ); Mon, 17 Jan 2022 21:19:51 -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 79A3BC061574; Mon, 17 Jan 2022 18:19:51 -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 17B32612CD; Tue, 18 Jan 2022 02:19:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46B12C36AF2; Tue, 18 Jan 2022 02:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472390; bh=Ye+NvjmveOKmvl6+16nojtYqOUgYxCut3gVhU6p2Vlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fCWdC8Ioso/ZaNoG/2TmWYQA6X24XRzPllkIeIBdU8BPin5eJ6t4QF8mlJcT4a5jW lDdtCS4a0PKQMyvtftI3X5crDx9rHJa7KmFSHaC6D5yFGLtnDyXJaad4KDBNk1v6SL S3yg3euzWaOB4DfNUl76CAJz3mE+PYPm2NXepCGsbNFXGNLPK8ZSRXct9VMDm6HTss ut+2gDKc0BzE6YqUV2B+jCNhilty5N0btOldUyLsHrXWUe/1JrbpWTY7El8hBnPIxC c1xTRXdQ/B+6Pv81oXpEHxMFPudJcU2ntuav0dKxUZXOUhl0OtP1FnUyxAcNE+BWWU a809ddlgW+G7w== 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.16 005/217] Bluetooth: Fix removing adv when processing cmd complete Date: Mon, 17 Jan 2022 21:16:08 -0500 Message-Id: <20220118021940.1942199-5-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-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: 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 7d0db1ca12482..41795851949f1 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