Skip to content

Commit a6a0fe1

Browse files
ujfalusiplbossart
authored andcommitted
fixup! ASoC: SOF: IPC4: Add pcm ops
Static analyzer reported: Pointer 'dai' returned from call to function 'snd_sof_find_dai' at line 181 may be NULL and will be dereferenced at line 184. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 82828fb commit a6a0fe1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

sound/soc/sof/ipc4-pcm.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,22 @@ static int sof_ipc4_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
181181
struct snd_sof_dai *dai = snd_sof_find_dai(component, rtd->dai_link->name);
182182
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
183183
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
184-
struct sof_ipc4_copier *ipc4_copier = dai->private;
184+
struct sof_ipc4_copier *ipc4_copier;
185185
struct snd_soc_dpcm *dpcm;
186186

187+
if (!dai) {
188+
dev_err(component->dev, "%s: No DAI found with name %s\n", __func__,
189+
rtd->dai_link->name);
190+
return -EINVAL;
191+
}
192+
193+
ipc4_copier = dai->private;
194+
if (!ipc4_copier) {
195+
dev_err(component->dev, "%s: No private data found for DAI %s\n",
196+
__func__, rtd->dai_link->name);
197+
return -EINVAL;
198+
}
199+
187200
/* always set BE format to 32-bits for both playback and capture */
188201
snd_mask_none(fmt);
189202
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S32_LE);

0 commit comments

Comments
 (0)