diff mbox

ALSA: core: check for underflow in snd_pcm_sw_params()

Message ID 20150923094228.GA13867@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Sept. 23, 2015, 9:42 a.m. UTC
As far as I can see, having an invalid ->tstamp_mode is harmless, but
adding a check silences a static checker warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Takashi Iwai Sept. 24, 2015, 9:46 a.m. UTC | #1
On Wed, 23 Sep 2015 11:42:28 +0200,
Dan Carpenter wrote:
> 
> As far as I can see, having an invalid ->tstamp_mode is harmless, but
> adding a check silences a static checker warning.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks.


Takashi

> 
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 75888dd..4863af5 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -650,7 +650,8 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
>  	}
>  	snd_pcm_stream_unlock_irq(substream);
>  
> -	if (params->tstamp_mode > SNDRV_PCM_TSTAMP_LAST)
> +	if (params->tstamp_mode < 0 ||
> +	    params->tstamp_mode > SNDRV_PCM_TSTAMP_LAST)
>  		return -EINVAL;
>  	if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12) &&
>  	    params->tstamp_type > SNDRV_PCM_TSTAMP_TYPE_LAST)
>
diff mbox

Patch

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 75888dd..4863af5 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -650,7 +650,8 @@  static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
 	}
 	snd_pcm_stream_unlock_irq(substream);
 
-	if (params->tstamp_mode > SNDRV_PCM_TSTAMP_LAST)
+	if (params->tstamp_mode < 0 ||
+	    params->tstamp_mode > SNDRV_PCM_TSTAMP_LAST)
 		return -EINVAL;
 	if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12) &&
 	    params->tstamp_type > SNDRV_PCM_TSTAMP_TYPE_LAST)