]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - sound/core/control.c
ALSA: control: Make sure that id->index does not overflow
[karo-tx-linux.git] / sound / core / control.c
index 8d6e4bae74074e99749f350bb3d245a1eb5ddc1b..f0b0e14497a5d3c5f066e6826cfbe836fb91c2ce 100644 (file)
@@ -342,6 +342,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
        if (snd_BUG_ON(!card || !kcontrol->info))
                goto error;
        id = kcontrol->id;
+       if (id.index > UINT_MAX - kcontrol->count)
+               goto error;
+
        down_write(&card->controls_rwsem);
        if (snd_ctl_find_id(card, &id)) {
                up_write(&card->controls_rwsem);