Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3173128rwb; Mon, 15 Aug 2022 20:05:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR4l9+V8D70twdV1tSaf91fl1zNtRTW96429ed5DAB5KtTy//hpGnuQx/DDQBVMDt+2CNYcJ X-Received: by 2002:a17:907:868b:b0:732:f83c:785a with SMTP id qa11-20020a170907868b00b00732f83c785amr12199048ejc.171.1660619114128; Mon, 15 Aug 2022 20:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660619114; cv=none; d=google.com; s=arc-20160816; b=hXapQbnep29eD6t3apOtVRwCQlQd+JjeeIeZiPci1tkhtuC6GCeG+03E1YIikbU95k FWf3PWeTO/7ds7S357A1AAddPSJP4tjw6ohCGgq24D58NeurNrg/kJiFbMG9JD9qUNRK RhfVT5FO/eKN0XSl+TuhvS/B1k1SFYkkngmh/fLXiHQM6GsMBE3hJmp5RLZAOottV9fj uuHwMnmeziFT0tXZc66T5HrhPiVDkS8rhxE8YoR9VEURxK1/tF7vyA3yvQMpK6GyvrlN OsANFWlkBU2MaUGXr8mlWwsg0N37PYR6AwQYJdjUH2hNeqxrTOnQC7nnZb+dpiQBmxM+ Xzzg== 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 :message-id:date:subject:to:from:dkim-signature; bh=OY8t43HKMKk9/dPk/QiOXNH/7gvwR0Dmd+QfnXfhHEE=; b=sEQN8pX5aflsT265oiVgqZfNHZWH4I5BD6DFkxtzEvJNMD3m2SdHbraXtsUU79FfXM lngCSEcKvyKvMt5v86+Uv2JU6+sDwsI123JiVYAmbUY/vX5UYiv6ketY3dYSKxwZ5ttG dW++Ar4Zd14BO3XwyPASfUspR4TFhgg98BsprFRbUBvrmT7wr3nezkaqpA/uIR+B407k hi0+1PK4ds5tCasdEpjnyeMQF8Co/fZ37zjVCv/iSor2ZhlIJL3moJNokFi4Opt9XDag WQ6Kdv9D0v4OmemMwTxLN6P3/+uHruOcA6FRbGXHmBoQhsRZViAmep/cmbUAr1bhT7U+ eJJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="iKdz/8M5"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o24-20020a1709064f9800b00732f74749ccsi7050951eju.581.2022.08.15.20.04.42; Mon, 15 Aug 2022 20:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="iKdz/8M5"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231739AbiHPCwZ (ORCPT + 99 others); Mon, 15 Aug 2022 22:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbiHPCwI (ORCPT ); Mon, 15 Aug 2022 22:52:08 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B8072C0D52 for ; Mon, 15 Aug 2022 16:20:13 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id s5-20020a17090a13c500b001f4da9ffe5fso15769112pjf.5 for ; Mon, 15 Aug 2022 16:20:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc; bh=OY8t43HKMKk9/dPk/QiOXNH/7gvwR0Dmd+QfnXfhHEE=; b=iKdz/8M52vFoeUcpXAO5ZZVFIvcfQpQOlGspt5NiZL+hwS6wYSOimFNuX+9yD0bagq /Bx5EvFLTCX54Dl/Fm925EjjmHwJepDaWtYKAMsouGOYOKSVZxxTVh5JjgGOzFsVLmPv VOUmV/IiSJKr0bS1hRJfthyuAg1mj2Nn+N52R5kZaetPUD6b8JZEWNMpjhEyYUampbom 8ZUfhUFRYlNEMpNmjpQW1V865UKeqKMq8Z/LCnfChEVVbVZ+INXvxEk5nf5bnYoyZwtZ p6sSNdjd1WDR06OJTeuVQhHpembsgl8GkLBi9UXQo834388P/33AQYkZY7pch3nilR7D ylew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc; bh=OY8t43HKMKk9/dPk/QiOXNH/7gvwR0Dmd+QfnXfhHEE=; b=SgyXyRzAqFzOkJUHOyr30FV80SgkEsCxByqX8QTIifehbyDUYMeEqjEOE+lH1pc2ek NZS34zKDitsdBpoTeS4691cCZG3d3+lXf3193hpvYQ6FIDQlCAdiBOJoNZUYovvoqN1U UyW09CQZ84WEELxM1QEhPoCuzLz1zyrFKmc7cO9HEWyd0q7KuCGtetaac+bxEFO5RG42 B+sETMohZZKg2pb52s+Ry/gmCCcoOsK8yIVNYUaNoUi8DP4MVZGs21DY3KB8Z3Y1fK8g PeKWAT5yAE2TNxk88D3k1lTBl0+6xeekCdt2oKgCfJFVkNAsvozgyECuJ4uLlxbFt71k 97vQ== X-Gm-Message-State: ACgBeo3xVgSgC+NfSKAHS4m58MWpZ++TAEg6fgAn+r//lDmcymKPhPok LeCG/Z/Y4gtDl++GOS6ZR2oB/rqKuyRjBw== X-Received: by 2002:a17:903:1cd:b0:171:3543:6b13 with SMTP id e13-20020a17090301cd00b0017135436b13mr19685446plh.96.1660605611893; Mon, 15 Aug 2022 16:20:11 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a6-20020a170902710600b0016ed20eacd2sm7464139pll.150.2022.08.15.16.20.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 16:20:11 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] adapter: Check flags are supported Date: Mon, 15 Aug 2022 16:20:06 -0700 Message-Id: <20220815232006.1252933-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes sure the flags are supported before attempting to set it. --- src/adapter.c | 4 +++- src/device.c | 5 +++++ src/device.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/adapter.c b/src/adapter.c index 3fa3018093b3..d33fc9bd661c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5428,10 +5428,12 @@ void adapter_set_device_flags(struct btd_adapter *adapter, mgmt_request_func_t func, void *user_data) { struct mgmt_cp_set_device_flags cp; + uint32_t supported = btd_device_get_supported_flags(device); const bdaddr_t *bdaddr; uint8_t bdaddr_type; - if (!btd_has_kernel_features(KERNEL_CONN_CONTROL)) + if (!btd_has_kernel_features(KERNEL_CONN_CONTROL) || + (supported | flags) != supported) return; bdaddr = device_get_address(device); diff --git a/src/device.c b/src/device.c index bc99420228d2..698c668b5420 100644 --- a/src/device.c +++ b/src/device.c @@ -6821,6 +6821,11 @@ uint32_t btd_device_get_current_flags(struct btd_device *dev) return dev->current_flags; } +uint32_t btd_device_get_supported_flags(struct btd_device *dev) +{ + return dev->supported_flags; +} + /* This event is sent immediately after add device on all mgmt sockets. * Afterwards, it is only sent to mgmt sockets other than the one which called * set_device_flags. diff --git a/src/device.h b/src/device.h index cc474bd889ec..9e81fda9e948 100644 --- a/src/device.h +++ b/src/device.h @@ -177,6 +177,7 @@ int device_discover_services(struct btd_device *device); int btd_device_connect_services(struct btd_device *dev, GSList *services); uint32_t btd_device_get_current_flags(struct btd_device *dev); +uint32_t btd_device_get_supported_flags(struct btd_device *dev); void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags, uint32_t current_flags); -- 2.37.2