diff options
Diffstat (limited to 'sound/core/pcm_lib.c')
| -rw-r--r-- | sound/core/pcm_lib.c | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 4f4b4739f987..f2090025236b 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -2128,11 +2128,28 @@ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,  {  	struct snd_pcm_runtime *runtime = substream->runtime;  	snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr; +	snd_pcm_sframes_t diff;  	int ret;  	if (old_appl_ptr == appl_ptr)  		return 0; +	if (appl_ptr >= runtime->boundary) +		return -EINVAL; +	/* +	 * check if a rewind is requested by the application +	 */ +	if (substream->runtime->info & SNDRV_PCM_INFO_NO_REWINDS) { +		diff = appl_ptr - old_appl_ptr; +		if (diff >= 0) { +			if (diff > runtime->buffer_size) +				return -EINVAL; +		} else { +			if (runtime->boundary + diff > runtime->buffer_size) +				return -EINVAL; +		} +	} +  	runtime->control->appl_ptr = appl_ptr;  	if (substream->ops->ack) {  		ret = substream->ops->ack(substream); |