mirror of https://github.com/thesofproject/sof.git
IPC: don't send uninitialised memory to the host
Currently multiple functions send struct sof_ipc_comp_reply to the host over IPC without initialising its .id field. To avoid this and similar problems in the future initialise reply objects in their definition statements. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
3de2368f4b
commit
0e309fdc16
|
@ -1045,7 +1045,12 @@ static int ipc_glb_tplg_comp_new(uint32_t header)
|
|||
{
|
||||
struct ipc *ipc = ipc_get();
|
||||
struct sof_ipc_comp comp;
|
||||
struct sof_ipc_comp_reply reply;
|
||||
struct sof_ipc_comp_reply reply = {
|
||||
.rhdr.hdr = {
|
||||
.cmd = header,
|
||||
.size = sizeof(reply),
|
||||
},
|
||||
};
|
||||
int ret;
|
||||
|
||||
/* copy message with ABI safe method */
|
||||
|
@ -1067,11 +1072,8 @@ static int ipc_glb_tplg_comp_new(uint32_t header)
|
|||
}
|
||||
|
||||
/* write component values to the outbox */
|
||||
reply.rhdr.hdr.size = sizeof(reply);
|
||||
reply.rhdr.hdr.cmd = header;
|
||||
reply.rhdr.error = 0;
|
||||
reply.offset = 0; /* TODO: set this up for mmaped components */
|
||||
mailbox_hostbox_write(0, &reply, sizeof(reply));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1079,7 +1081,12 @@ static int ipc_glb_tplg_buffer_new(uint32_t header)
|
|||
{
|
||||
struct ipc *ipc = ipc_get();
|
||||
struct sof_ipc_buffer ipc_buffer;
|
||||
struct sof_ipc_comp_reply reply;
|
||||
struct sof_ipc_comp_reply reply = {
|
||||
.rhdr.hdr = {
|
||||
.cmd = header,
|
||||
.size = sizeof(reply),
|
||||
},
|
||||
};
|
||||
int ret;
|
||||
|
||||
/* copy message with ABI safe method */
|
||||
|
@ -1102,11 +1109,8 @@ static int ipc_glb_tplg_buffer_new(uint32_t header)
|
|||
}
|
||||
|
||||
/* write component values to the outbox */
|
||||
reply.rhdr.hdr.size = sizeof(reply);
|
||||
reply.rhdr.hdr.cmd = header;
|
||||
reply.rhdr.error = 0;
|
||||
reply.offset = 0; /* TODO: set this up for mmaped components */
|
||||
mailbox_hostbox_write(0, &reply, sizeof(reply));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1114,7 +1118,12 @@ static int ipc_glb_tplg_pipe_new(uint32_t header)
|
|||
{
|
||||
struct ipc *ipc = ipc_get();
|
||||
struct sof_ipc_pipe_new ipc_pipeline;
|
||||
struct sof_ipc_comp_reply reply;
|
||||
struct sof_ipc_comp_reply reply = {
|
||||
.rhdr.hdr = {
|
||||
.cmd = header,
|
||||
.size = sizeof(reply),
|
||||
},
|
||||
};
|
||||
int ret;
|
||||
|
||||
/* copy message with ABI safe method */
|
||||
|
@ -1135,11 +1144,8 @@ static int ipc_glb_tplg_pipe_new(uint32_t header)
|
|||
}
|
||||
|
||||
/* write component values to the outbox */
|
||||
reply.rhdr.hdr.size = sizeof(reply);
|
||||
reply.rhdr.hdr.cmd = header;
|
||||
reply.rhdr.error = 0;
|
||||
reply.offset = 0; /* TODO: set this up for mmaped components */
|
||||
mailbox_hostbox_write(0, &reply, sizeof(reply));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue