Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sound/soc/sof/ipc4-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ static int sof_ipc4_compr_stream_free(struct snd_sof_dev *sdev,
int ret = 0;
int err = 0;

if (!pcm_ops)
return -EINVAL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ujfalusi Is it possible be NULL?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During normal stream ops sdev->ipc->ops is always set, so pcm_ops will not be NULL at runtime.
But sof_ipc_get_ops(sdev, pcm) evaluates to
((sdev)->ipc && (sdev)->ipc->ops) ? (sdev)->ipc->ops->pcm : NULL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes? This is granted to be never NULL.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is granted to be not NULL.


if (spcm->prepared[dir]) {
if (spcm->pending_stop[dir])
pcm_ops->trigger(sdev->component, NULL, spcm,
Expand Down Expand Up @@ -542,6 +545,9 @@ static int sof_ipc4_compr_trigger(struct snd_soc_component *component,
bool trigger_platform = false;
int ret = 0;

if (!pcm_ops || !pcm_ops->trigger)
return -EINVAL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of this is granted.
This is IPC4 compress code, supporting IPC4, IPC4 have these callbacks, ops.
If we are in DSPless mode than the pd->compress_ops is kept NULL, so this code cannot be called.

The report is bogus.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only reason for this PR is,
SOF CI job build test / GCC static -fanalyzer FAILS with -Werror=analyzer-null-dereference because of NULL branch in sof_ipc_get_ops()
Leading to https://github.com/thesofproject/linux/actions/runs/33356184832/job/99378699428?pr=5903

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, static analyzer is wrong.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even other soc-vendors also observes similar issue - but atleast with this PR, Intel is fine
https://github.com/thesofproject/linux/actions/runs/33360526770/job/99390844949?pr=5905

Else do you recommend to handle this at macro level(something like correcting sof_ipc_get_ops() in sof-priv.h), instead of scattering NULL checks in individual audio stream.
Or do you recommend to Leave this as is ?
Please share your thoughts. Thanks


spcm = snd_sof_find_spcm_dai(component, rtd);
if (!spcm) {
dev_err(sdev->dev, "%s: can't find spcm\n", __func__);
Expand Down
Loading