Skip to content

Commit b4da02f

Browse files
serhiy-katsyuba-intellgirdwood
authored andcommitted
kpb: Fix crash after a reset
The kpb->host_sink is NULL after a reset or unbind. The host could send a reset IPC while the draining task is still running, which results in a crash. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
1 parent 7ddf208 commit b4da02f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/audio/kpb.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,9 +1850,15 @@ static enum task_state kpb_draining_task(void *arg)
18501850
out:
18511851
draining_time_end = sof_cycle_get_64();
18521852

1853-
/* Reset host-sink copy mode back to its pre-draining value */
1854-
comp_set_attribute(comp_buffer_get_sink_component(kpb->host_sink), COMP_ATTR_COPY_TYPE,
1855-
&kpb->draining_task_data.copy_type);
1853+
/* Reset host-sink copy mode back to its pre-draining value.
1854+
* kpb->host_sink is NULL after a reset or unbind.
1855+
*/
1856+
if (kpb->host_sink)
1857+
comp_set_attribute(comp_buffer_get_sink_component(kpb->host_sink),
1858+
COMP_ATTR_COPY_TYPE,
1859+
&kpb->draining_task_data.copy_type);
1860+
else
1861+
comp_cl_err(&comp_kpb, "Failed to restore host copy mode!");
18561862

18571863
draining_time_ms = k_cyc_to_ms_near64(draining_time_end - draining_time_start);
18581864
if (draining_time_ms <= UINT_MAX)

0 commit comments

Comments
 (0)