瀏覽代碼

ALSA: pcm core - add a safe check to the silence filling function

In situation when appl_ptr is far greater then hw_ptr, the hw_avail value
can be greater than buffer_size. Check for this.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav Kysela 15 年之前
父節點
當前提交
9e216e8a40
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      sound/core/pcm_lib.c

+ 2 - 0
sound/core/pcm_lib.c

@@ -67,6 +67,8 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
 	} else {
 	} else {
 		if (new_hw_ptr == ULONG_MAX) {	/* initialization */
 		if (new_hw_ptr == ULONG_MAX) {	/* initialization */
 			snd_pcm_sframes_t avail = snd_pcm_playback_hw_avail(runtime);
 			snd_pcm_sframes_t avail = snd_pcm_playback_hw_avail(runtime);
+			if (avail > runtime->buffer_size)
+				avail = runtime->buffer_size;
 			runtime->silence_filled = avail > 0 ? avail : 0;
 			runtime->silence_filled = avail > 0 ? avail : 0;
 			runtime->silence_start = (runtime->status->hw_ptr +
 			runtime->silence_start = (runtime->status->hw_ptr +
 						  runtime->silence_filled) %
 						  runtime->silence_filled) %