Commit 9cf0e452 authored by Imre Deak's avatar Imre Deak Committed by Mark Brown

ASoC: Intel: byt/hsw: Add missing kthread_stop to error/cleanup path

Baytrail and Haswell SST IPC don't stop the kernel thread in error and
cleanup path thus leaving orphan kernel thread behind in such a case.

Also while at it, fix one error path in sst-haswell-ipc.c that doesn't free
hsw->msg.

[Jarkko: I edited the commit log a little]
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Signed-off-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 9b351d46
...@@ -907,7 +907,7 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) ...@@ -907,7 +907,7 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata)
byt->dsp = sst_dsp_new(dev, &byt_dev, pdata); byt->dsp = sst_dsp_new(dev, &byt_dev, pdata);
if (byt->dsp == NULL) { if (byt->dsp == NULL) {
err = -ENODEV; err = -ENODEV;
goto err_free_msg; goto dsp_err;
} }
/* keep the DSP in reset state for base FW loading */ /* keep the DSP in reset state for base FW loading */
...@@ -940,6 +940,8 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) ...@@ -940,6 +940,8 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata)
sst_fw_free(byt_sst_fw); sst_fw_free(byt_sst_fw);
fw_err: fw_err:
sst_dsp_free(byt->dsp); sst_dsp_free(byt->dsp);
dsp_err:
kthread_stop(byt->tx_thread);
err_free_msg: err_free_msg:
kfree(byt->msg); kfree(byt->msg);
...@@ -954,6 +956,7 @@ void sst_byt_dsp_free(struct device *dev, struct sst_pdata *pdata) ...@@ -954,6 +956,7 @@ void sst_byt_dsp_free(struct device *dev, struct sst_pdata *pdata)
sst_dsp_reset(byt->dsp); sst_dsp_reset(byt->dsp);
sst_fw_free_all(byt->dsp); sst_fw_free_all(byt->dsp);
sst_dsp_free(byt->dsp); sst_dsp_free(byt->dsp);
kthread_stop(byt->tx_thread);
kfree(byt->msg); kfree(byt->msg);
} }
EXPORT_SYMBOL_GPL(sst_byt_dsp_free); EXPORT_SYMBOL_GPL(sst_byt_dsp_free);
...@@ -1730,7 +1730,7 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) ...@@ -1730,7 +1730,7 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata)
ret = msg_empty_list_init(hsw); ret = msg_empty_list_init(hsw);
if (ret < 0) if (ret < 0)
goto list_err; return -ENOMEM;
/* start the IPC message thread */ /* start the IPC message thread */
init_kthread_worker(&hsw->kworker); init_kthread_worker(&hsw->kworker);
...@@ -1740,7 +1740,7 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) ...@@ -1740,7 +1740,7 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata)
if (IS_ERR(hsw->tx_thread)) { if (IS_ERR(hsw->tx_thread)) {
ret = PTR_ERR(hsw->tx_thread); ret = PTR_ERR(hsw->tx_thread);
dev_err(hsw->dev, "error: failed to create message TX task\n"); dev_err(hsw->dev, "error: failed to create message TX task\n");
goto list_err; goto err_free_msg;
} }
init_kthread_work(&hsw->kwork, ipc_tx_msgs); init_kthread_work(&hsw->kwork, ipc_tx_msgs);
...@@ -1750,7 +1750,7 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) ...@@ -1750,7 +1750,7 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata)
hsw->dsp = sst_dsp_new(dev, &hsw_dev, pdata); hsw->dsp = sst_dsp_new(dev, &hsw_dev, pdata);
if (hsw->dsp == NULL) { if (hsw->dsp == NULL) {
ret = -ENODEV; ret = -ENODEV;
goto list_err; goto dsp_err;
} }
/* keep the DSP in reset state for base FW loading */ /* keep the DSP in reset state for base FW loading */
...@@ -1794,8 +1794,11 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) ...@@ -1794,8 +1794,11 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata)
sst_fw_free(hsw_sst_fw); sst_fw_free(hsw_sst_fw);
fw_err: fw_err:
sst_dsp_free(hsw->dsp); sst_dsp_free(hsw->dsp);
dsp_err:
kthread_stop(hsw->tx_thread);
err_free_msg:
kfree(hsw->msg); kfree(hsw->msg);
list_err:
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(sst_hsw_dsp_init); EXPORT_SYMBOL_GPL(sst_hsw_dsp_init);
...@@ -1808,6 +1811,7 @@ void sst_hsw_dsp_free(struct device *dev, struct sst_pdata *pdata) ...@@ -1808,6 +1811,7 @@ void sst_hsw_dsp_free(struct device *dev, struct sst_pdata *pdata)
sst_fw_free_all(hsw->dsp); sst_fw_free_all(hsw->dsp);
sst_dsp_free(hsw->dsp); sst_dsp_free(hsw->dsp);
kfree(hsw->scratch); kfree(hsw->scratch);
kthread_stop(hsw->tx_thread);
kfree(hsw->msg); kfree(hsw->msg);
} }
EXPORT_SYMBOL_GPL(sst_hsw_dsp_free); EXPORT_SYMBOL_GPL(sst_hsw_dsp_free);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment