ALSA: pcm: harmless underflow issue in snd_pcm_sw_params()
diff mbox

Message ID 20151013070756.GA31537@mwanda
State New
Headers show

Commit Message

Dan Carpenter Oct. 13, 2015, 7:07 a.m. UTC
"params->tstamp_mode" is a user supplied int.  We cap the maximum but
allow negative values by mistake.  It's harmless but static checkers
complain.

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

Comments

Takashi Iwai Oct. 13, 2015, 9:39 a.m. UTC | #1
On Tue, 13 Oct 2015 09:07:56 +0200,
Dan Carpenter wrote:
> 
> "params->tstamp_mode" is a user supplied int.  We cap the maximum but
> allow negative values by mistake.  It's harmless but static checkers
> complain.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

You already sent the same fix and it was applied in the commit
145d92e77e6f.


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)
>
Dan Carpenter Oct. 13, 2015, 12:06 p.m. UTC | #2
On Tue, Oct 13, 2015 at 11:39:41AM +0200, Takashi Iwai wrote:
> On Tue, 13 Oct 2015 09:07:56 +0200,
> Dan Carpenter wrote:
> > 
> > "params->tstamp_mode" is a user supplied int.  We cap the maximum but
> > allow negative values by mistake.  It's harmless but static checkers
> > complain.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> You already sent the same fix and it was applied in the commit
> 145d92e77e6f.
> 

Oops.  Sorry about that.

regards,
dan carpenter

Patch
diff mbox

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)