]> git.alsa-project.org Git - alsa-lib.git/commitdiff
topology: decode: Change declaration of enum decoding function
authorPiotr Maziarz <piotrx.maziarz@linux.intel.com>
Mon, 31 Aug 2020 09:08:59 +0000 (11:08 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 31 Aug 2020 11:03:01 +0000 (13:03 +0200)
Size constraints are always checked before invoking
tplg_decode_control_enum1. There is no need to validate it twice.
Alos moved debug print about size to invoking function, since now it's it
responsibility to check size.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/topology/ctl.c
src/topology/dapm.c
src/topology/tplg_local.h

index 1f3984616a654b004d23a5bcdb7ed58ccde3f5aa..47db400fd4d1a7b065fd7aa1f320dc5663f1d7ba 100644 (file)
@@ -1335,22 +1335,10 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg,
                              struct list_head *heap,
                              struct snd_tplg_enum_template *et,
                              size_t pos,
-                             void *bin, size_t size)
+                             struct snd_soc_tplg_enum_control *ec)
 {
-       struct snd_soc_tplg_enum_control *ec = bin;
        int i;
 
-       if (size < sizeof(*ec)) {
-               SNDERR("enum: small size %d", size);
-               return -EINVAL;
-       }
-
-       tplg_log(tplg, 'D', pos, "enum: size %d private size %d",
-                ec->size, ec->priv.size);
-       if (size != ec->size + ec->priv.size) {
-               SNDERR("enum: unexpected element size %d", size);
-               return -EINVAL;
-       }
        if (ec->num_channels > SND_TPLG_MAX_CHAN ||
            ec->num_channels > SND_SOC_TPLG_MAX_CHAN) {
                SNDERR("enum: unexpected channel count %d", ec->num_channels);
@@ -1427,7 +1415,10 @@ next:
                return -EINVAL;
        }
 
-       err = tplg_decode_control_enum1(tplg, &heap, &et, pos, bin, size);
+       tplg_log(tplg, 'D', pos, "enum: size %d private size %d",
+                ec->size, ec->priv.size);
+
+       err = tplg_decode_control_enum1(tplg, &heap, &et, pos, ec);
        if (err >= 0) {
                t.enum_ctl = &et;
                err = snd_tplg_add_object(tplg, &t);
index cd1a87704681c15402ad261268db666f62874b27..73a9390340c2001091d71eb38c6c0ae964d7c4d6 100644 (file)
@@ -972,8 +972,7 @@ next:
                                err = -EINVAL;
                                goto retval;
                        }
-                       err = tplg_decode_control_enum1(tplg, &heap, et, pos,
-                                                       bin, size2);
+                       err = tplg_decode_control_enum1(tplg, &heap, et, pos, ec);
                        break;
                case SND_SOC_TPLG_TYPE_BYTES:
                        bt = tplg_calloc(&heap, sizeof(*bt));
index 5ace0d1919e1fa233fa4d5b6187dbc3d6c49a497..acb01a831f301021d667101861832fb1287bc01b 100644 (file)
@@ -398,7 +398,7 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg,
                              struct list_head *heap,
                              struct snd_tplg_enum_template *et,
                              size_t pos,
-                             void *bin, size_t size);
+                             struct snd_soc_tplg_enum_control *ec);
 int tplg_decode_control_enum(snd_tplg_t *tplg, size_t pos,
                             struct snd_soc_tplg_hdr *hdr,
                             void *bin, size_t size);