* [bug report] ASoC: amd: Add common framework to support I2S on ACP SOC
@ 2022-08-18 11:16 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-08-18 11:16 UTC (permalink / raw)
To: AjitKumar.Pandey; +Cc: alsa-devel
Hello Ajit Kumar Pandey,
The patch 623621a9f9e1: "ASoC: amd: Add common framework to support
I2S on ACP SOC" from Oct 19, 2021, leads to the following Smatch
static checker warning:
sound/soc/amd/acp/acp-platform.c:199 acp_dma_open()
warn: '&stream->list' not removed from list
sound/soc/amd/acp/acp-platform.c
173 static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_substream *substream)
174 {
175 struct snd_pcm_runtime *runtime = substream->runtime;
176 struct device *dev = component->dev;
177 struct acp_dev_data *adata = dev_get_drvdata(dev);
178 struct acp_stream *stream;
179 int ret;
180
181 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
182 if (!stream)
183 return -ENOMEM;
184
185 stream->substream = substream;
186
187 spin_lock_irq(&adata->acp_lock);
188 list_add_tail(&stream->list, &adata->stream_list);
Stream added to the list
189 spin_unlock_irq(&adata->acp_lock);
190
191 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
192 runtime->hw = acp_pcm_hardware_playback;
193 else
194 runtime->hw = acp_pcm_hardware_capture;
195
196 ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
197 if (ret < 0) {
198 dev_err(component->dev, "set integer constraint failed\n");
--> 199 kfree(stream);
Use after free.
200 return ret;
201 }
202 runtime->private_data = stream;
203
204 writel(1, ACP_EXTERNAL_INTR_ENB(adata));
205
206 return ret;
Could we delay adding the stream to the list until right before this
"return 0;"?
207 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-18 11:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-18 11:16 [bug report] ASoC: amd: Add common framework to support I2S on ACP SOC Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.