codec_adapter: fix panic during reset

If module_prepare() fails, the pipeline will be reset resulting in
module_reset() getting invoked. Just return if the state is <
MODULE_IDLE which indicates that the module was never prepared.
Also, in this case, local_buff is never allocated. So, check if it is
NULL before zeroing it out to avoid DSP panic.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
Ranjani Sridharan 2022-01-13 19:03:09 -08:00 committed by Liam Girdwood
parent c75d794913
commit 8effa4ff3d
2 changed files with 8 additions and 1 deletions

View File

@ -307,6 +307,10 @@ int module_reset(struct comp_dev *dev)
struct processing_module *mod = comp_get_drvdata(dev);
struct module_data *md = &mod->priv;
/* if the module was never prepared, no need to reset */
if (md->state < MODULE_IDLE)
return 0;
ret = md->ops->reset(dev);
if (ret) {
comp_err(dev, "module_reset() error %d: module specific reset() failed for comp %d",

View File

@ -584,7 +584,10 @@ int codec_adapter_reset(struct comp_dev *dev)
comp_err(dev, "codec_adapter_reset(): error %d, codec reset has failed",
ret);
}
buffer_zero(mod->local_buff);
/* if module is not prepared, local_buffer won't be allocated */
if (mod->local_buff)
buffer_zero(mod->local_buff);
comp_dbg(dev, "codec_adapter_reset(): done");