Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2711451pxv; Sun, 11 Jul 2021 23:29:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznvDCr9ZZPFBgqlnLUyxHcdzzf2lHifBfLBVQaTceOB3/D6/b7JZAgU5hH++/IUSDWY5Hf X-Received: by 2002:a05:6402:5114:: with SMTP id m20mr63799505edd.174.1626071391346; Sun, 11 Jul 2021 23:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071391; cv=none; d=google.com; s=arc-20160816; b=fHtRggEtdY4wP+7KBo0vA58cRcSqvT+7k3KcssJazgZV2zbkBU/LIE+p3SmuJmMY55 E3YvnvZTfjW2Bc7lIt13j5CrtFtNsNl07wZjr0/nKosfGzjBjDvw3qbyyHwEB7xiwi/4 /gue4GyyX7sDpTFAh3OuU957kt6Mu+qMoCQSjpHk3TlqFeTLqt5SfMx2XWU0Xkvz0GUm Tt/VZJtqv/z9jnemb42wI4ea4sWC/G5FleO2SMyqdqhntCDGRLKthTdJA+ArOnzfa9aM OiDfTjHbpO6mTFzbIeiu+UStHKGizLJn44cDt59e3QWdjIyPpAAKTvO6fzmOL+pDdC1Z Clog== 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=1BEl14VJzSuL+Y0BD0s2zqCYao1vOTrvymNc+gmSz2M=; b=IWo/YQ1OcQmEYmMbTt+RaxobnwevkxI4G+OQMQ4N0mbMXoukQk9dBY+DTPW4izrJlj YW60SRaUG53onyqBArHJfo11Ue+Pu6Ol6TdQVLNIharRmLjFNqoxJA/sYpwinuk004NJ 9hm9q8nzRmNxf4CfZaCPcc8Wmj5dTDxc62eiGFDgc/pO618NgTZ/2XqNWbhXGg9xC5yq 91E2BW0RsvdDkR2W/BfAbkjJwSqH++x136z7SFGyilFnvwNAXXsTdblwhU951ltBIT4M hSBsDGRMlqF8tvs86TUXPyt4w2Kp/nlvQwHAnQ0UsRta9cqdNcXPTxpha0FvwVoTK85F fDqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iqBSk7ZW; 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 y7si16098641ejc.395.2021.07.11.23.29.28; Sun, 11 Jul 2021 23:29:51 -0700 (PDT) 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=iqBSk7ZW; 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 S234699AbhGLGbP (ORCPT + 99 others); Mon, 12 Jul 2021 02:31:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:47908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235043AbhGLG1F (ORCPT ); Mon, 12 Jul 2021 02:27:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7BEAE61156; Mon, 12 Jul 2021 06:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071030; bh=Nr4jhejmZHuCeoux78xZk12/ld6IdUjciVg7/OatO5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqBSk7ZWZ6q+ZgWR5lwYYG306Y4hrBIEAKilkKxHQutmAZij2WMeGNJ/OfONvF7aU EIFzkOe51oYx3MOg/dzJhnzDrsSFjqQyNIOH8xTiEDThc3ls2LRblzZq3QJ5ab545w vLDeRLZ80F4sNZuu03oppNTuWwVwEHPGcQOrDUbo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.4 243/348] Bluetooth: Fix handling of HCI_LE_Advertising_Set_Terminated event Date: Mon, 12 Jul 2021 08:10:27 +0200 Message-Id: <20210712060734.838013768@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@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: Luiz Augusto von Dentz [ Upstream commit 23837a6d7a1a61818ed94a6b8af552d6cf7d32d5 ] Error status of this event means that it has ended due reasons other than a connection: 'If advertising has terminated as a result of the advertising duration elapsing, the Status parameter shall be set to the error code Advertising Timeout (0x3C).' 'If advertising has terminated because the Max_Extended_Advertising_Events was reached, the Status parameter shall be set to the error code Limit Reached (0x43).' Fixes: acf0aeae431a0 ("Bluetooth: Handle ADv set terminated event") Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hci_event.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index bd678ffdaef7..e8e7f108b016 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5101,8 +5101,19 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); - if (ev->status) + if (ev->status) { + struct adv_info *adv; + + adv = hci_find_adv_instance(hdev, ev->handle); + if (!adv) + return; + + /* Remove advertising as it has been terminated */ + hci_remove_adv_instance(hdev, ev->handle); + mgmt_advertising_removed(NULL, hdev, ev->handle); + return; + } conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); if (conn) { -- 2.30.2