Skip to contentSkip to conversation

ALSA: dice: fix a bounds check in snd_dice_detect_tcelectronic_formats()

PATCH Applied Dan Carpenter 3 participants 3 messages May 18, 2018

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

PATCH 1/1 ALSA: dice: fix a bounds check in snd_dice_detect_tcelectronic_formats()

The "entry" pointer is always non-NULL so this test for out of bounds won't work.

Fixes f1f0f330b1d0 ("ALSA: dice: add parameters of stream formats for models produced by TC Electronic")
sound/firewire/dice/dice-tcelectronic.c +1 -2
index af8203b9d1a6..e134a5110c6c 100644
@@ -75,13 +75,12 @@ int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice)
 		}
 	}
 
-	entry = NULL;
 	for (i = 0; i < ARRAY_SIZE(entries); ++i) {
 		entry = entries + i;
 		if (entry->model_id = model_id)
 			break;
 	}
-	if (!entry)
+	if (i = ARRAY_SIZE(entries))
 		return -ENODEV;
 
 	memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 15 lines · Dan Carpenter

The "entry" pointer is always non-NULL so this test for out of bounds won't work.

Fixes f1f0f330b1d0 ("ALSA: dice: add parameters of stream formats for models produced by TC Electronic")
sound/firewire/dice/dice-tcelectronic.c +0 -1
index af8203b9d1a6..e134a5110c6c 100644
@@ -75,13 +75,12 @@ int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice)
  		}
  	}
 
-	entry = NULL;

sound/firewire/dice/dice-tcelectronic.c int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice) · line 86

Quoted 10 lines
sound/firewire/dice/dice-tcelectronic.c +1 -1
  	for (i = 0; i < ARRAY_SIZE(entries); ++i) {
  		entry = entries + i;
  		if (entry->model_id = model_id)
  			break;
  	}
-	if (!entry)
+	if (i = ARRAY_SIZE(entries))
  		return -ENODEV;
 
  	memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,

Oops, indeed.

Thanks

Takashi Sakamoto