From a83bfcb453ee271738deebedc6efbf8473009aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Battrel?= Date: Thu, 20 Feb 2025 08:42:15 +0100 Subject: [PATCH] [nrf fromlist] Bluetooth: Host: Use `memset` to initialize `psa_mac_operation_t` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `db_hash_setup()` the state object for MAC operations was initialized using `psa_mac_operation_init()`. This function was not always optimized or inlined. A way to reduce stack usage is to use `memset()` and set the object to 0. This is one of the option documented to initialize `psa_mac_operation_t` object. Upstream PR #: 86094 Signed-off-by: Théo Battrel --- subsys/bluetooth/host/gatt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 7ea10083d0f..688512b74f8 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -717,7 +717,7 @@ static int db_hash_setup(struct gen_hash_state *state, uint8_t *key) LOG_ERR("Unable to import the key for AES CMAC %d", ret); return -EIO; } - state->operation = psa_mac_operation_init(); + memset(&state->operation, 0, sizeof(state->operation)); ret = psa_mac_sign_setup(&(state->operation), state->key, PSA_ALG_CMAC); if (ret != PSA_SUCCESS) {