提交 0fbb027b 编写于 作者: T Takashi Iwai

ALSA: pcm: Fix double hw_free calls

The commit 66f2d19f ("ALSA: pcm: Fix memory leak at closing a
stream without hw_free") tried to fix the regression wrt the missing
hw_free call at closing without SNDRV_PCM_IOCTL_HW_FREE ioctl.
However, the code change dropped mistakenly the state check, resulting
in calling hw_free twice when SNDRV_PCM_IOCTL_HW_FRE got called
beforehand.  For most drivers, this is almost harmless, but the
drivers like SOF show another regression now.

This patch adds the state condition check before calling do_hw_free()
at releasing the stream for avoiding the double hw_free calls.

Fixes: 66f2d19f ("ALSA: pcm: Fix memory leak at closing a stream without hw_free")
Reported-by: NBard Liao <yung-chuan.liao@linux.intel.com>
Reported-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tested-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/s5hd0ajyprg.wl-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
上级 9f35a312
......@@ -2594,7 +2594,8 @@ void snd_pcm_release_substream(struct snd_pcm_substream *substream)
snd_pcm_drop(substream);
if (substream->hw_opened) {
do_hw_free(substream);
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
do_hw_free(substream);
substream->ops->close(substream);
substream->hw_opened = 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册