ipc4: don't keep stale pointers, avoid double freeing

When freeing memory it's also good to clear the pointer to avoid
use-after-free or double-free bugs.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2024-02-26 10:53:14 +01:00 committed by Liam Girdwood
parent 081bcab6ef
commit 6795011794
1 changed files with 4 additions and 1 deletions

View File

@ -1332,8 +1332,11 @@ struct ipc_cmd_hdr *ipc_prepare_to_send(const struct ipc_msg *msg)
mailbox_dspbox_write(0, (uint32_t *)msg->tx_data, msg->tx_size);
/* free memory for get config function */
if (msg == &msg_reply && msg_reply.tx_size > 0)
if (msg == &msg_reply && msg_reply.tx_size > 0) {
rfree(msg_reply.tx_data);
msg_reply.tx_data = NULL;
msg_reply.tx_size = 0;
}
return &msg_data.msg_out;
}