From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03C4CC2D0CE for ; Sun, 29 Dec 2019 18:06:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D45B3206A4 for ; Sun, 29 Dec 2019 18:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577642777; bh=bgoLrfBiDlptMFs2tOuC55hGOOupU3TAiJZe3ZtPpY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zmLusiy4l5VEz4OWSO6SpCdBeM4XD0bXy8WXYgexMJTSyfegoz23yTopNOSptxIHL GTq8I5/tNloS3+HrpGd9+IFT25cxvtmBXMSnUgBzR/0DWRDn7qEJrHZoH7pMtFjTqJ ndI6L6s3bk+M7Sr9Trw2Gg+7AWoWeRdQlnJJMgZM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731813AbfL2RuM (ORCPT ); Sun, 29 Dec 2019 12:50:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:34514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731808AbfL2RuM (ORCPT ); Sun, 29 Dec 2019 12:50:12 -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 35FD220718; Sun, 29 Dec 2019 17:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641811; bh=bgoLrfBiDlptMFs2tOuC55hGOOupU3TAiJZe3ZtPpY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=la91mIA+Vna5KC1L0Bw3nIug2MjqSCeNqlUrB3y/MFVZJSex6w9D1sN4/ET/kD4K2 dT8COb+QRAzm5x9U/ZBWssZW/h4N8ZJ+5WJoQ4CHAMbrAfT7gd9L65zt5j4ClMvkyc Fv8k203DvcKMxoyg1j4S4q1KLDG+0ZWijqxU9tgg= 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 5.4 220/434] Bluetooth: Fix advertising duplicated flags Date: Sun, 29 Dec 2019 18:24:33 +0100 Message-Id: <20191229172716.453350446@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 7f6a581b5b7e..3d25dbf10b26 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1273,6 +1273,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. */ @@ -1305,6 +1313,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