From c5a5bf1793d0b26f2c50a01e8f8245a751d94cb0 Mon Sep 17 00:00:00 2001 From: Rafal Redzimski Date: Fri, 22 Apr 2022 15:05:26 +0200 Subject: [PATCH] ipc: fix ipc_msg_init call to use preinitialized structure fields ipc_msg_init should use the already initialized size field in rhdr structure instead using the sizeof. Signed-off-by: Rafal Redzimski --- src/audio/google_hotword_detect.c | 2 +- src/audio/host.c | 2 +- src/audio/pipeline/pipeline-graph.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/google_hotword_detect.c b/src/audio/google_hotword_detect.c index b854e1be9..415487599 100644 --- a/src/audio/google_hotword_detect.c +++ b/src/audio/google_hotword_detect.c @@ -116,7 +116,7 @@ static struct comp_dev *ghd_create(const struct comp_driver *drv, cd->event.event_type = SOF_CTRL_EVENT_KD; cd->event.num_elems = 0; - cd->msg = ipc_msg_init(cd->event.rhdr.hdr.cmd, sizeof(cd->event)); + cd->msg = ipc_msg_init(cd->event.rhdr.hdr.cmd, cd->event.rhdr.size); if (!cd->msg) { comp_err(dev, "ghd_create(): ipc_msg_init failed"); goto cd_fail; diff --git a/src/audio/host.c b/src/audio/host.c index 9c090e361..7ee10e7d1 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -659,7 +659,7 @@ static struct comp_dev *host_new(const struct comp_driver *drv, ipc_build_stream_posn(&hd->posn, SOF_IPC_STREAM_POSITION, dev->ipc_config.id); - hd->msg = ipc_msg_init(hd->posn.rhdr.hdr.cmd, sizeof(hd->posn)); + hd->msg = ipc_msg_init(hd->posn.rhdr.hdr.cmd, hd->posn.rhdr.hdr.size); if (!hd->msg) { comp_err(dev, "host_new(): ipc_msg_init failed"); dma_put(hd->dma); diff --git a/src/audio/pipeline/pipeline-graph.c b/src/audio/pipeline/pipeline-graph.c index b05b2e605..534d3e7a1 100644 --- a/src/audio/pipeline/pipeline-graph.c +++ b/src/audio/pipeline/pipeline-graph.c @@ -146,7 +146,7 @@ struct pipeline *pipeline_new(uint32_t pipeline_id, uint32_t priority, uint32_t /* just for retrieving valid ipc_msg header */ ipc_build_stream_posn(&posn, SOF_IPC_STREAM_TRIG_XRUN, p->comp_id); - p->msg = ipc_msg_init(posn.rhdr.hdr.cmd, sizeof(posn)); + p->msg = ipc_msg_init(posn.rhdr.hdr.cmd, posn.rhdr.hdr.size); if (!p->msg) { pipe_err(p, "pipeline_new(): ipc_msg_init failed"); rfree(p);