Skip to content

Commit

Permalink
[nrf fromlist] Bluetooth: Host: Use memset to initialize `psa_mac_o…
Browse files Browse the repository at this point in the history
…peration_t`

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 <[email protected]>
  • Loading branch information
theob-pro committed Feb 25, 2025
1 parent 50128e3 commit 0a869ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0a869ab

Please sign in to comment.