The address of a data structure member was determined before a corresponding null pointer check in the implementation of the function “hda_dsp_iccmax_stream_hw_params”.
Thus avoid the risk for undefined behaviour by moving the assignment for three local variables behind some condition checks.
This issue was detected by using the Coccinelle software.
Fixes: 7d88b9608142f95ccdd3dfb190da4a5faddb1cc7 ("ASoC: SOF: Intel: hdac_ext_stream: consistent prefixes for variables/members") Signed-off-by: Markus Elfring elfring@users.sourceforge.net
Yes indeed, for some reason this was fixed in hda_dsp_stream_hw_params() but not in the hda_dsp_iccmax_stream_hw_params() variant.
Would Peter Ujfalusi like to support similar source code adjustments also according to his commit 09255c7ed8ca1f1ed99357b845d2f63fe2ef3e1e ("ASoC: SOF: Intel: hda-stream: Do not dereference hstream until it is safe") from 2023-04-04?
Could we however use the same code as in hda_dsp_stream_hw_params() for consistency?
…
hstream = &hext_stream->hstream; sd_offset = SOF_STREAM_SD_OFFSET(hstream); mask = BIT(hstream->index);
Can it matter to move such assignment statements a bit closer to subsequent statements?
Regards, Markus