Skip to content

Commit f6e0862

Browse files
krish2718nordicjm
authored andcommitted
[nrf fromlist] net: lib: tls_credentials_shell: Fix crash during delete
Deletion of credential should use the pointer from the reference slot not the temporary buffer, this causes a crash (unknown error). Upstream PR #: 87656 Signed-off-by: Chaitanya Tata <[email protected]>
1 parent e3269af commit f6e0862

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/net/lib/tls_credentials/tls_credentials_shell.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ static int tls_cred_cmd_del(const struct shell *sh, size_t argc, char *argv[])
564564
ref_slot = find_ref_slot(cred->buf);
565565
if (ref_slot >= 0) {
566566
/* This was a credential we copied to heap. Clear and free it. */
567-
memset((void *)cred_buf, 0, cred->len);
568-
k_free((void *)cred_buf);
567+
memset(&cred_refs[ref_slot], 0, cred->len);
568+
k_free((void *)&cred_refs[ref_slot]);
569569
cred->buf = NULL;
570570

571571
/* Clear the reference slot so it can be used again. */

0 commit comments

Comments
 (0)