From 27dd9027a36022c63403bfeaabc8c592bba99a41 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 24 Jun 2021 15:01:50 -0700 Subject: [PATCH] adapter: Fix toggling of experimental features When toggling experimental features it may cause the old value to still be in effect since it was read after read info which upon completion would attempt to call adapter_register without first updating the experimental features which could affect the likes of advertising instances when LL Privacy is enabled. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- src/adapter.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 6d2c755..3677f7a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -15524,14 +15524,15 @@ static void set_exp_debug_complete(uint8_t status, uint16_t len, static void exp_debug_func(struct btd_adapter *adapter, uint32_t flags) { struct mgmt_cp_set_exp_feature cp; + uint8_t action = btd_opts.experimental ? 0x01 : 0x00; - /* If already enabled don't attempt to set it again */ - if (flags & BIT(0)) + /* If already set don't attempt to set it again */ + if (action == (flags & BIT(0))) return; memset(&cp, 0, sizeof(cp)); memcpy(cp.uuid, debug_uuid, 16); - cp.action = 0x01; + cp.action = btd_opts.experimental ? 0x01 : 0x00; if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE, adapter->dev_id, sizeof(cp), &cp, @@ -15560,14 +15561,15 @@ static void set_rpa_resolution_complete(uint8_t status, uint16_t len, static void rpa_resolution_func(struct btd_adapter *adapter, uint32_t flags) { struct mgmt_cp_set_exp_feature cp; + uint8_t action = btd_opts.experimental ? 0x01 : 0x00; - /* If already enabled don't attempt to set it again */ - if (flags & BIT(0)) + /* If already set don't attempt to set it again */ + if (action == (flags & BIT(0))) return; memset(&cp, 0, sizeof(cp)); memcpy(cp.uuid, rpa_resolution_uuid, 16); - cp.action = 0x01; + cp.action = action; if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE, adapter->dev_id, sizeof(cp), &cp, @@ -15782,10 +15784,6 @@ static void read_info_complete(uint8_t status, uint16_t length, adapter->central_rpa_res_support = 0x01; #endif - if (btd_opts.experimental && - btd_has_kernel_features(KERNEL_EXP_FEATURES)) - read_exp_features(adapter); - err = adapter_register(adapter); if (err < 0) { btd_error(adapter->dev_id, "Unable to register new adapter"); @@ -16090,6 +16088,9 @@ static void index_added(uint16_t index, uint16_t length, const void *param, return; } + if (btd_has_kernel_features(KERNEL_EXP_FEATURES)) + read_exp_features(adapter); + /* * Protect against potential two executions of read controller info. * -- 2.7.4