Skip to contentSkip to conversation

ALSA: core: check for underflow in snd_pcm_sw_params()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 23, 2015 – Sep 24, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

As far as I can see, having an invalid ->tstamp_mode is harmless, but adding a check silences a static checker warning.

sound/core/pcm_native.c +2 -1
index 75888dd..4863af5 100644
@@ -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)
Applied
#1 lore raw
Quoted 5 lines · Dan Carpenter

As far as I can see, having an invalid ->tstamp_mode is harmless, but adding a check silences a static checker warning.

Applied, thanks.

Takashi

Quoted 16 lines
sound/core/pcm_native.c +2 -1
index 75888dd..4863af5 100644
@@ -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)