From: Jaroslav Kysela Date: Mon, 19 Jul 2010 14:37:39 +0000 (+0200) Subject: ALSA: pcm core - add a safe check to the silence filling function X-Git-Tag: v3.0~3585^2~16^2~9^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e216e8a40428cbf689222148c28d0256fbd0186;p=platform%2Fkernel%2Flinux-amlogic.git 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 --- diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index bcf95d3..e23e0e7 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -67,6 +67,8 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram } else { if (new_hw_ptr == ULONG_MAX) { /* initialization */ 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_start = (runtime->status->hw_ptr + runtime->silence_filled) %