Repository navigation
audio: pipeline: guard against NULL source or sink in pipeline_copy() #11184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
Comment on lines
+189
to
193
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is valid. Pipeline execution and IPC handling (that modifes the graph) is never run concurrnetly. IPC actions are run when LL pipelines are not run. So I think this is safe.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@kv2019i not sure I understand you correctly. Maybe you mean a narrow set of cases. In general it is very much possible: LL and IPC can run on different cores (in all combinations: primary IPC, secondary LL, or the opposite, or both on secondary cores), and IPC can be preempted by LL on the same core. Could you clarify? |
||
| 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; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style not, a "goto err: " to common exit with PPL_UNLOCK would look a bit better (but would require initializing ret to something). Given single-line cleanup, not a blocker.