* [PATCH v4 0/1] Fix driver reload issues @ 2019-07-26 9:09 Amadeusz Sławiński 2019-07-26 9:09 ` [PATCH v4 1/1] ASoC: Intel: Skylake: Remove static table index when parsing topology Amadeusz Sławiński 0 siblings, 1 reply; 3+ messages in thread From: Amadeusz Sławiński @ 2019-07-26 9:09 UTC (permalink / raw) To: alsa-devel Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown, Pierre-Louis Bossart, Jie Yang, Cezary Rojewski, linux-kernel, Amadeusz Sławiński Hi, this is last patch left from series fixing driver reload problems. Rebased onto latest for-next in Marks tree. Amadeusz Sławiński (1): ASoC: Intel: Skylake: Remove static table index when parsing topology sound/soc/intel/skylake/skl-topology.c | 34 +++++++++----------------- 1 file changed, 12 insertions(+), 22 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v4 1/1] ASoC: Intel: Skylake: Remove static table index when parsing topology 2019-07-26 9:09 [PATCH v4 0/1] Fix driver reload issues Amadeusz Sławiński @ 2019-07-26 9:09 ` Amadeusz Sławiński 2019-07-26 15:47 ` [alsa-devel] " Pierre-Louis Bossart 0 siblings, 1 reply; 3+ messages in thread From: Amadeusz Sławiński @ 2019-07-26 9:09 UTC (permalink / raw) To: alsa-devel Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown, Pierre-Louis Bossart, Jie Yang, Cezary Rojewski, linux-kernel, Amadeusz Sławiński 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> --- sound/soc/intel/skylake/skl-topology.c | 34 +++++++++----------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 118866cd5075..c1c37ce759bd 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -3333,25 +3333,6 @@ static int skl_tplg_get_int_tkn(struct device *dev, 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 * type. @@ -3362,6 +3343,7 @@ static int skl_tplg_get_manifest_tkn(struct device *dev, { int tkn_count = 0, ret; int off = 0, tuple_size = 0; + u8 uuid_index = 0; struct snd_soc_tplg_vendor_array *array; struct snd_soc_tplg_vendor_value_elem *tkn_elem; @@ -3384,9 +3366,17 @@ static int skl_tplg_get_manifest_tkn(struct device *dev, continue; case SND_SOC_TPLG_TUPLE_TYPE_UUID: - ret = skl_tplg_get_manifest_uuid(dev, skl, array->uuid); - if (ret < 0) - return ret; + if (array->uuid->token != SKL_TKN_UUID) { + dev_err(dev, "Not an UUID token: %d\n", + 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); continue; -- 2.17.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [alsa-devel] [PATCH v4 1/1] ASoC: Intel: Skylake: Remove static table index when parsing topology 2019-07-26 9:09 ` [PATCH v4 1/1] ASoC: Intel: Skylake: Remove static table index when parsing topology Amadeusz Sławiński @ 2019-07-26 15:47 ` Pierre-Louis Bossart 0 siblings, 0 replies; 3+ messages in thread From: Pierre-Louis Bossart @ 2019-07-26 15:47 UTC (permalink / raw) To: Amadeusz Sławiński, alsa-devel Cc: Cezary Rojewski, linux-kernel, Takashi Iwai, Jie Yang, Liam Girdwood, Mark Brown On 7/26/19 4:09 AM, Amadeusz Sławiński wrote: > 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> > --- > sound/soc/intel/skylake/skl-topology.c | 34 +++++++++----------------- > 1 file changed, 12 insertions(+), 22 deletions(-) > > diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c > index 118866cd5075..c1c37ce759bd 100644 > --- a/sound/soc/intel/skylake/skl-topology.c > +++ b/sound/soc/intel/skylake/skl-topology.c > @@ -3333,25 +3333,6 @@ static int skl_tplg_get_int_tkn(struct device *dev, > 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 > * type. > @@ -3362,6 +3343,7 @@ static int skl_tplg_get_manifest_tkn(struct device *dev, > { > int tkn_count = 0, ret; > int off = 0, tuple_size = 0; > + u8 uuid_index = 0; > struct snd_soc_tplg_vendor_array *array; > struct snd_soc_tplg_vendor_value_elem *tkn_elem; > > @@ -3384,9 +3366,17 @@ static int skl_tplg_get_manifest_tkn(struct device *dev, > continue; > > case SND_SOC_TPLG_TUPLE_TYPE_UUID: > - ret = skl_tplg_get_manifest_uuid(dev, skl, array->uuid); > - if (ret < 0) > - return ret; > + if (array->uuid->token != SKL_TKN_UUID) { > + dev_err(dev, "Not an UUID token: %d\n", > + 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); > continue; > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-26 15:47 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-07-26 9:09 [PATCH v4 0/1] Fix driver reload issues Amadeusz Sławiński 2019-07-26 9:09 ` [PATCH v4 1/1] ASoC: Intel: Skylake: Remove static table index when parsing topology Amadeusz Sławiński 2019-07-26 15:47 ` [alsa-devel] " Pierre-Louis Bossart
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).