Skip to content

Commit da2b540

Browse files
singalsulgirdwood
authored andcommitted
audio: pipeline: guard against NULL source or sink in pipeline_copy()
Freeing the endpoint component of a pipeline clears pipeline->source_comp or pipeline->sink_comp. If the pipeline is still scheduled after that, pipeline_copy() dereferences p->source_comp->direction or starts the copy walk from a NULL component, and the DSP panics. The SOF driver does not free the components of a running pipeline, but the firmware should not crash on out of order IPCs either. The crash was seen in about 10% of runs when capturing from the KPB and MWW PCMs of a KPB + MFCC + MWW topology. Add NULL checks for p->source_comp and the start component of the copy walk, and return 0 without copying if an endpoint is gone. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 8668c10 commit da2b540

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎src/audio/pipeline/pipeline-stream.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ int pipeline_copy(struct pipeline *p)
179179

180180
PPL_LOCK(p->core);
181181

182+
/*
183+
* Freeing the endpoint component of a pipeline clears p->source_comp
184+
* or p->sink_comp. The driver does not free the components of a
185+
* running pipeline, but out of order IPCs or a misbehaving host must
186+
* not crash the DSP, so skip the copy if an endpoint is gone.
187+
*/
188+
if (!p->source_comp) {
189+
PPL_UNLOCK();
190+
return 0;
191+
}
192+
182193
if (p->source_comp->direction == SOF_IPC_STREAM_PLAYBACK) {
183194
dir = PPL_DIR_UPSTREAM;
184195
start = p->sink_comp;
@@ -187,6 +198,12 @@ int pipeline_copy(struct pipeline *p)
187198
start = p->source_comp;
188199
}
189200

201+
/* The endpoint at the start of the copy walk is gone, see above */
202+
if (!start) {
203+
PPL_UNLOCK();
204+
return 0;
205+
}
206+
190207
data.start = start;
191208
data.p = p;
192209

0 commit comments

Comments
 (0)