Skip to content

Commit eaad9b8

Browse files
ujfalusikv2019i
authored andcommitted
ipc: Fix IPC message sending with payload already prepared
If the msg->tx_size/data have been prepared by caller and it calls the function with NULL as data: ipc_msg_send(msg, NULL, false); then we try to copy from NULL to the msg->tx_data because msg->tx_data != data is true. The callers could be fixed as well, but the ipc_msg_send() and ipc_msg_send_direct() should handle this. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 8ac6367 commit eaad9b8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/ipc/ipc-common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ __cold void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
205205
key = k_spin_lock(&ipc->lock);
206206

207207
/* copy mailbox data to message if not already copied */
208-
if (msg->tx_size > 0 && msg->tx_size <= SOF_IPC_MSG_MAX_SIZE &&
208+
if (data && msg->tx_size > 0 && msg->tx_size <= SOF_IPC_MSG_MAX_SIZE &&
209209
msg->tx_data != data) {
210210
ret = memcpy_s(msg->tx_data, msg->tx_size, data, msg->tx_size);
211211
assert(!ret);
@@ -225,7 +225,7 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
225225
key = k_spin_lock(&ipc->lock);
226226

227227
/* copy mailbox data to message if not already copied */
228-
if ((msg->tx_size > 0 && msg->tx_size <= SOF_IPC_MSG_MAX_SIZE) &&
228+
if (data && (msg->tx_size > 0 && msg->tx_size <= SOF_IPC_MSG_MAX_SIZE) &&
229229
msg->tx_data != data) {
230230
ret = memcpy_s(msg->tx_data, msg->tx_size, data, msg->tx_size);
231231
assert(!ret);

0 commit comments

Comments
 (0)