Fix: Use module manifest from toml as a template for elf modules

Some platforms (eg. tgl) dont have modules configuration in a toml files.
An attempt to use the configuration template ended with a reference to
a null pointer. This commit fixes this issue.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
This commit is contained in:
Adrian Warecki 2023-04-06 15:42:23 +02:00 committed by Liam Girdwood
parent 25804e7dc8
commit ab0429fdbe
2 changed files with 9 additions and 4 deletions

View File

@ -662,9 +662,13 @@ static int man_create_modules(struct image *image, struct sof_man_fw_desc *desc,
for (; i < image->num_modules; i++) {
man_module = (void *)desc + SOF_MAN_MODULE_OFFSET(i - offset);
/* Use manifest created using toml files as template */
assert(i < image->adsp->modules->mod_man_count);
memcpy(man_module, &image->adsp->modules->mod_man[i], sizeof(*man_module));
/* Some platforms dont have modules configuration in toml file */
if (image->adsp->modules) {
/* Use manifest created using toml files as template */
assert(i < image->adsp->modules->mod_man_count);
memcpy(man_module, &image->adsp->modules->mod_man[i], sizeof(*man_module));
}
module = &image->module[i];

View File

@ -206,7 +206,8 @@ int main(int argc, char *argv[])
goto out;
}
if (image.num_modules > image.adsp->modules->mod_man_count) {
/* Some platforms dont have modules configuration in toml file */
if (image.adsp->modules && image.num_modules > image.adsp->modules->mod_man_count) {
fprintf(stderr, "error: Each ELF input module requires entry in toml file.\n");
ret = -EINVAL;
goto out;