ASoC: Intel: Skylake: Remove static table index when parsing topology

Currently when we remove and reload driver we use previous ref_count
value to start iterating over skl->modules which leads to out of table
access. To fix this just inline the function and calculate indexes
everytime we parse UUID token.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190726090929.27946-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Amadeusz Sławiński 2019-07-26 11:09:29 +02:00 committed by Mark Brown
parent c8415833ec
commit 096769ea95
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 12 additions and 22 deletions

View File

@ -3333,25 +3333,6 @@ static int skl_tplg_get_int_tkn(struct device *dev,
return tkn_count; return tkn_count;
} }
static int skl_tplg_get_manifest_uuid(struct device *dev,
struct skl_dev *skl,
struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
{
static int ref_count;
struct skl_module *mod;
if (uuid_tkn->token == SKL_TKN_UUID) {
mod = skl->modules[ref_count];
guid_copy(&mod->uuid, (guid_t *)&uuid_tkn->uuid);
ref_count++;
} else {
dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token);
return -EINVAL;
}
return 0;
}
/* /*
* Fill the manifest structure by parsing the tokens based on the * Fill the manifest structure by parsing the tokens based on the
* type. * type.
@ -3362,6 +3343,7 @@ static int skl_tplg_get_manifest_tkn(struct device *dev,
{ {
int tkn_count = 0, ret; int tkn_count = 0, ret;
int off = 0, tuple_size = 0; int off = 0, tuple_size = 0;
u8 uuid_index = 0;
struct snd_soc_tplg_vendor_array *array; struct snd_soc_tplg_vendor_array *array;
struct snd_soc_tplg_vendor_value_elem *tkn_elem; struct snd_soc_tplg_vendor_value_elem *tkn_elem;
@ -3384,9 +3366,17 @@ static int skl_tplg_get_manifest_tkn(struct device *dev,
continue; continue;
case SND_SOC_TPLG_TUPLE_TYPE_UUID: case SND_SOC_TPLG_TUPLE_TYPE_UUID:
ret = skl_tplg_get_manifest_uuid(dev, skl, array->uuid); if (array->uuid->token != SKL_TKN_UUID) {
if (ret < 0) dev_err(dev, "Not an UUID token: %d\n",
return ret; array->uuid->token);
return -EINVAL;
}
if (uuid_index >= skl->nr_modules) {
dev_err(dev, "Too many UUID tokens\n");
return -EINVAL;
}
guid_copy(&skl->modules[uuid_index++]->uuid,
(guid_t *)&array->uuid->uuid);
tuple_size += sizeof(*array->uuid); tuple_size += sizeof(*array->uuid);
continue; continue;