From 37d7a9602e087cbdd558196cefa526a86697cb08 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 9 Sep 2026 14:16:50 +0300 Subject: [PATCH] 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 --- src/audio/pipeline/pipeline-stream.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/audio/pipeline/pipeline-stream.c b/src/audio/pipeline/pipeline-stream.c index 5fd795e818db..b63ace5c08c6 100644 --- a/src/audio/pipeline/pipeline-stream.c +++ b/src/audio/pipeline/pipeline-stream.c @@ -179,6 +179,17 @@ int pipeline_copy(struct pipeline *p) PPL_LOCK(p->core); + /* + * Freeing the endpoint component of a pipeline clears p->source_comp + * or p->sink_comp. The driver does not free the components of a + * running pipeline, but out of order IPCs or a misbehaving host must + * not crash the DSP, so skip the copy if an endpoint is gone. + */ + if (!p->source_comp) { + PPL_UNLOCK(); + return 0; + } + if (p->source_comp->direction == SOF_IPC_STREAM_PLAYBACK) { dir = PPL_DIR_UPSTREAM; start = p->sink_comp; @@ -187,6 +198,12 @@ int pipeline_copy(struct pipeline *p) start = p->source_comp; } + /* The endpoint at the start of the copy walk is gone, see above */ + if (!start) { + PPL_UNLOCK(); + return 0; + } + data.start = start; data.p = p;