tools: tplg_parser: check if parameter is valid before using it

Before accessing the contents of the parameter pointer of the
function, check if the pointer is NULL. Else, it may lead to
segmentation fault.

Signed-off-by: Mohana Datta Yelugoti <ymdatta.work@gmail.com>
This commit is contained in:
Mohana Datta Yelugoti 2020-07-30 17:39:29 +00:00 committed by Liam Girdwood
parent 0bf3ca6a8b
commit bc1d785b4d
1 changed files with 5 additions and 0 deletions

View File

@ -1114,6 +1114,11 @@ int load_widget(void *dev, int dev_type, struct comp_info *temp_comp_list,
size_t size;
int ret = 0;
if (!temp_comp_list) {
fprintf(stderr, "load_widget: temp_comp_list argument NULL\n");
return -EINVAL;
}
/* allocate memory for widget */
size = sizeof(struct snd_soc_tplg_dapm_widget);
widget = (struct snd_soc_tplg_dapm_widget *)malloc(size);