Commit b0fb75ad authored by Dan Carpenter's avatar Dan Carpenter Committed by Takashi Iwai

ALSA: es1688: add pedantic range checks

Smatch complains that if (dev == SNDRV_CARDS) we're one past the end of
the array.  That's unlikely to happen in real life, I suppose.

Also smatch complains about "strcpy(card->shortname, pcm->name);"
The "pcm->name" buffer is 80 characters and "card->shortname" is 32
characters.  If you follow the call paths it turns out we never actually
use more than 16 characters so it's not a problem.  But anyway, let's
make it easy for people auditing this in the future.
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 89485d49
...@@ -149,10 +149,11 @@ static int __devinit snd_es1688_probe(struct snd_card *card, unsigned int n) ...@@ -149,10 +149,11 @@ static int __devinit snd_es1688_probe(struct snd_card *card, unsigned int n)
if (error < 0) if (error < 0)
return error; return error;
strcpy(card->driver, "ES1688"); strlcpy(card->driver, "ES1688", sizeof(card->driver));
strcpy(card->shortname, pcm->name); strlcpy(card->shortname, pcm->name, sizeof(card->shortname));
sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, snprintf(card->longname, sizeof(card->longname),
chip->port, chip->irq, chip->dma8); "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port,
chip->irq, chip->dma8);
if (fm_port[n] == SNDRV_AUTO_PORT) if (fm_port[n] == SNDRV_AUTO_PORT)
fm_port[n] = port[n]; /* share the same port */ fm_port[n] = port[n]; /* share the same port */
...@@ -271,6 +272,8 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *pcard, ...@@ -271,6 +272,8 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *pcard,
if (enable[dev] && isapnp[dev]) if (enable[dev] && isapnp[dev])
break; break;
} }
if (dev == SNDRV_CARDS)
return -ENODEV;
error = snd_card_create(index[dev], id[dev], THIS_MODULE, error = snd_card_create(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_es1688), &card); sizeof(struct snd_es1688), &card);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment