Skip to content

Commit 608dbfd

Browse files
LingaoMrlubos
authored andcommitted
[nrf fromlist] Bluetooth: Mesh: fix PrivateBeaconKey PSA key leak on subnet delete
subnet_keys_destroy() guarded the destroy of keys->priv_beacon with matching import with #if defined(CONFIG_BT_MESH_PRIV_BEACONS). Commit 981c79b ("Bluetooth: Mesh: Drop explicit support for Bluetooth Mesh 1.0.1") removed the CONFIG_BT_MESH_V1d1 Kconfig but left this stray reference behind. With V1d1 gone, the destroy branch is permanently dead code, so every successful net_keys_create() leaks one PSA key slot. In a long-running test that repeatedly provisions and resets a node (no persistent settings, in-RAM CDB only), the leak accumulates one PSA volatile-key slot per provisioning round. With the default CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT=16, bt_mesh_private_beacon_key() fails after ~12 rounds with: <err> bt_mesh_net_keys: Unable to generate private beacon key <err> bt_mesh_net: Failed creating subnet <err> bt_mesh_main: Failed to create network Align the destroy guard with the import guard so the leak goes away. Upstream PR #: 110235 Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
1 parent 966c138 commit 608dbfd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

subsys/bluetooth/mesh/subnet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static void subnet_keys_destroy(struct bt_mesh_subnet_keys *key)
202202
#if defined(CONFIG_BT_MESH_GATT_PROXY)
203203
bt_mesh_key_destroy(&key->identity);
204204
#endif
205-
#if defined(CONFIG_BT_MESH_V1d1)
205+
#if defined(CONFIG_BT_MESH_PRIV_BEACONS)
206206
bt_mesh_key_destroy(&key->priv_beacon);
207207
#endif
208208
}

0 commit comments

Comments
 (0)