Skip to content

Commit c477d1f

Browse files
joerchanrlubos
authored andcommitted
lib: modem_key_mgmt: Fix missing lock of scratch buffer
Fix missing lock of the internal scratch buffer in modem_key_mgmt_clear function. Signed-off-by: Joakim Andersson <[email protected]>
1 parent a99a26b commit c477d1f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/modem_key_mgmt/modem_key_mgmt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,16 @@ int modem_key_mgmt_clear(nrf_sec_tag_t sec_tag)
297297

298298
cmee_enable(&cmee_was_enabled);
299299

300+
k_mutex_lock(&key_mgmt_mutex, K_FOREVER);
301+
300302
err = nrf_modem_at_cmd(scratch_buf, sizeof(scratch_buf), "AT%%CMNG=1, %d", sec_tag);
301303

302304
if (!cmee_was_enabled) {
303305
cmee_disable();
304306
}
305307

306308
if (err) {
307-
return translate_error(err);
309+
goto out;
308310
}
309311

310312
token = strtok(scratch_buf, "\n");
@@ -317,6 +319,8 @@ int modem_key_mgmt_clear(nrf_sec_tag_t sec_tag)
317319
token = strtok(NULL, "\n");
318320
}
319321

322+
out:
323+
k_mutex_unlock(&key_mgmt_mutex);
320324
if (err) {
321325
return translate_error(err);
322326
}

0 commit comments

Comments
 (0)