ASoC: SOF: ipc4-compress: Add NULL checks for pcm_ops - #5905
ASoC: SOF: ipc4-compress: Add NULL checks for pcm_ops#5905naveen-manohar wants to merge 1 commit into
Conversation
Patch adds NULL checks before dereferencing pcm_ops to prevent potential NULL pointer deref issues & fix -Werror=analyzer-null-dereference build failures. Signed-off-by: Naveen Manohar <naveen.m@intel.com>
| int err = 0; | ||
|
|
||
| if (!pcm_ops) | ||
| return -EINVAL; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
yes? This is granted to be never NULL.
| int err = 0; | ||
|
|
||
| if (!pcm_ops) | ||
| return -EINVAL; |
There was a problem hiding this comment.
this is granted to be not NULL.
| int ret = 0; | ||
|
|
||
| if (!pcm_ops || !pcm_ops->trigger) | ||
| return -EINVAL; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Yes, static analyzer is wrong.
There was a problem hiding this comment.
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
Patch adds NULL checks before dereferencing pcm_ops
to prevent potential NULL pointer deref issues & fix
-Werror=analyzer-null-dereference build failures.
Addresses Issue - https://github.com/thesofproject/linux/actions/runs/33356184832/job/99378699428?pr=5903