Skip to content

Commit 0fbb027

Browse files
committed
ALSA: pcm: Fix double hw_free calls
The commit 66f2d19 ("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: 66f2d19 ("ALSA: pcm: Fix memory leak at closing a stream without hw_free") Reported-by: Bard Liao <[email protected]> Reported-by: Pierre-Louis Bossart <[email protected]> Tested-by: Pierre-Louis Bossart <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 9f35a31 commit 0fbb027

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sound/core/pcm_native.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,8 @@ void snd_pcm_release_substream(struct snd_pcm_substream *substream)
25942594

25952595
snd_pcm_drop(substream);
25962596
if (substream->hw_opened) {
2597-
do_hw_free(substream);
2597+
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
2598+
do_hw_free(substream);
25982599
substream->ops->close(substream);
25992600
substream->hw_opened = 0;
26002601
}

0 commit comments

Comments
 (0)