From 64e1d0c3be487f2d6765050d8056bf9fdfd2afaa Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Fri, 10 Nov 2023 14:50:41 +0100 Subject: [PATCH] bluetooth: mesh: Don't write to const value `bt_mesh_default_key` is declared as const and thus located in flash. `bt_mesh_cdb_subnet_key_export` tries to copy to that address which results in a Bus Fault. Use separate array for storing net_key. Signed-off-by: Pavel Vasilyev --- subsys/bluetooth/mesh/shell/shell.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/mesh/shell/shell.c b/subsys/bluetooth/mesh/shell/shell.c index 6ee825d4c09..c1bad5d24ad 100644 --- a/subsys/bluetooth/mesh/shell/shell.c +++ b/subsys/bluetooth/mesh/shell/shell.c @@ -944,7 +944,7 @@ static int cmd_provision_adv(const struct shell *sh, size_t argc, static int cmd_provision_local(const struct shell *sh, size_t argc, char *argv[]) { - uint8_t *net_key = (uint8_t *)bt_mesh_shell_default_key; + uint8_t net_key[16]; uint16_t net_idx, addr; uint32_t iv_index; int err = 0; @@ -963,6 +963,8 @@ static int cmd_provision_local(const struct shell *sh, size_t argc, char *argv[] return err; } + memcpy(net_key, bt_mesh_shell_default_key, sizeof(net_key)); + if (IS_ENABLED(CONFIG_BT_MESH_CDB)) { struct bt_mesh_cdb_subnet *sub;