Skip to content

Commit

Permalink
ASoC: Intel: check and clear runtime module pointer
Browse files Browse the repository at this point in the history
Add check runtime module pointers before freeing them, and clear
them to NULL after freed.

With this implemented, we can avoid NULL pointer dereference or
double free errors.

Signed-off-by: Jie Yang <yang.jie@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Jie Yang authored and Mark Brown committed Jun 2, 2015
1 parent 6e5132f commit 2dbc80c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sound/soc/intel/haswell/sst-haswell-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,10 +928,15 @@ static void hsw_pcm_free_modules(struct hsw_priv_data *pdata)

for (i = 0; i < ARRAY_SIZE(mod_map); i++) {
pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream];
sst_hsw_runtime_module_free(pcm_data->runtime);
if (pcm_data->runtime){
sst_hsw_runtime_module_free(pcm_data->runtime);
pcm_data->runtime = NULL;
}
}
if (sst_hsw_is_module_loaded(hsw, SST_HSW_MODULE_WAVES)) {
if (sst_hsw_is_module_loaded(hsw, SST_HSW_MODULE_WAVES) &&
pdata->runtime_waves) {
sst_hsw_runtime_module_free(pdata->runtime_waves);
pdata->runtime_waves = NULL;
}
}

Expand Down

0 comments on commit 2dbc80c

Please sign in to comment.