@@ -1680,7 +1680,7 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
const struct sof_ipc_pcm_ops *ipc_pcm_ops = sof_ipc_get_ops(sdev, pcm);
struct snd_soc_tplg_stream_caps *caps;
- struct snd_soc_tplg_private *private = &pcm->priv;
+ struct snd_soc_tplg_private *private;
struct snd_sof_pcm *spcm;
int stream;
int ret;
@@ -1716,6 +1716,7 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
dai_drv->dobj.private = spcm;
list_add(&spcm->list, &sdev->pcm_list);
+ private = &pcm->priv;
ret = sof_parse_tokens(scomp, spcm, stream_tokens,
ARRAY_SIZE(stream_tokens), private->array,
le32_to_cpu(private->size));
Date: Thu, 13 Apr 2023 13:56:44 +0200 The address of a data structure member was determined before a corresponding null pointer check in the implementation of the function “sof_dai_load”. Thus avoid the risk for undefined behaviour by moving the assignment for the local variable “private” behind some condition checks. This issue was detected by using the Coccinelle software. Fixes: c5232c0171428f005a3204e1c264231fb5999b28 ("ASoC: SOF: topology: parse and store d0i3_compatible flag") Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- sound/soc/sof/topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.40.0