Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13336334ybl; Sun, 29 Dec 2019 09:34:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxyk7Kyap2e5pI7r2/htn/V6OzEaJap9yqqAulJ3MqGMEh5FExRqfuOqzwR7x+sz1Ix1iHh X-Received: by 2002:a9d:6745:: with SMTP id w5mr54634495otm.52.1577640860071; Sun, 29 Dec 2019 09:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640860; cv=none; d=google.com; s=arc-20160816; b=AcA+Wg+QIxnPcrb1L7T5Agi9XX1BHFdgOkQbj9vVKzNB1HRQC+o7WbDmWJlulh9VP9 b0upXVgCF5NxAZfOhyomrMouuZowNO5iOzso4ColBS/YNYH0RhEpKkwRjHwctT1tCwOe 8WAprmaMclkQKszB1mm+Ri7BwOGzJmXOkbqHPigcqHnHUyrBgOseWpAMSQ8Uxi/Ieq1y TzuSs7kIOfh7rZU4NmQl2kiL0TMsfnXIstz9Ogk5bi/xuXFafTV6kvuzL+TLr+ZVdTRc XF84c3AJywYRjQnFYPp5RkdwlLaOyccTrkIZa3aiyUkyj041BHxWaLY8MgX5cI0++8hr PQ0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ja/xLv0HoS/Gw6ep1Dx7xkVPuqLAZ9iMKPzoihCCrIA=; b=A4zBwi6GQqyCYdi2DCGUQPjTUHBtVyS50AW9owGkZDuDBE9dbT53M9NWXrhicamZZj l+ZDR+p8X2mbCMJjKzxsHOQdrfzQ/jPSed5nm93fyUIqHHC59qGz9Le1UoQV1ZCMJcL3 bZzTiCMvsHLwketr0ZBDwLbcBEi95TirmBTtdBwzsMwQBskawuMCsS8qFHUjg38oN2Sd 6Euzmt25R7Ys1gr7fUo9qw605HHWXpMeNFbVJDdvrRbXYuX0ckMkVF8lIoXhkpMpmU6X 32tMPqLzGbJawOTCWCgZ1cIwyOgl8YorMpYpBHeCvELPO2ZQb641zIV8XDZ3uE/45VgU CJ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ot52PBzf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u25si19374474otg.170.2019.12.29.09.34.08; Sun, 29 Dec 2019 09:34:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ot52PBzf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729263AbfL2RcI (ORCPT + 99 others); Sun, 29 Dec 2019 12:32:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:60222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729251AbfL2RcE (ORCPT ); Sun, 29 Dec 2019 12:32:04 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D01920409; Sun, 29 Dec 2019 17:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640723; bh=V8+AX6NmgPrCd7u5ESCMAsVXX3stlJexHiOjmb4Ny5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ot52PBzfxAbKGNvxX02bdokgCkKawX8FiS8wK/ZmjbWSdYPENuV39GXcaqJe8tziI i1SjlwmxpesampiVh4J+eScnRp+r1Fn5XrNWeX6r/Wj2GAOUrOlX1G/6NyRychb36D P2lIr/GfCBHVoexwEHDuJH9YyC426fZx3Bm4Jtnw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Johan Hedberg , Sasha Levin Subject: [PATCH 4.19 112/219] Bluetooth: Fix advertising duplicated flags Date: Sun, 29 Dec 2019 18:18:34 +0100 Message-Id: <20191229162525.553429215@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luiz Augusto von Dentz [ Upstream commit 6012b9346d8959194c239fd60a62dfec98d43048 ] Instances may have flags set as part of its data in which case the code should not attempt to add it again otherwise it can cause duplication: < HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 35 Handle: 0x00 Operation: Complete extended advertising data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x06 Flags: 0x04 BR/EDR Not Supported Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Johan Hedberg Signed-off-by: Sasha Levin --- net/bluetooth/hci_request.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 9448ebd3780a..a8ddd211e94c 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1258,6 +1258,14 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) instance_flags = get_adv_instance_flags(hdev, instance); + /* If instance already has the flags set skip adding it once + * again. + */ + if (adv_instance && eir_get_data(adv_instance->adv_data, + adv_instance->adv_data_len, EIR_FLAGS, + NULL)) + goto skip_flags; + /* The Add Advertising command allows userspace to set both the general * and limited discoverable flags. */ @@ -1290,6 +1298,7 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) } } +skip_flags: if (adv_instance) { memcpy(ptr, adv_instance->adv_data, adv_instance->adv_data_len); -- 2.20.1