提交 99e09b9c 编写于 作者: K Krzysztof Kozlowski 提交者: Vinod Koul

soundwire: qcom: add proper error paths in qcom_swrm_startup()

Reverse actions in qcom_swrm_startup() error paths to avoid leaking
stream memory and keeping runtime PM unbalanced.
Signed-off-by: NKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230517163736.997553-1-krzysztof.kozlowski@linaro.orgSigned-off-by: NVinod Koul <vkoul@kernel.org>
上级 700581ed
...@@ -1099,8 +1099,10 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream, ...@@ -1099,8 +1099,10 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,
} }
sruntime = sdw_alloc_stream(dai->name); sruntime = sdw_alloc_stream(dai->name);
if (!sruntime) if (!sruntime) {
return -ENOMEM; ret = -ENOMEM;
goto err_alloc;
}
ctrl->sruntime[dai->id] = sruntime; ctrl->sruntime[dai->id] = sruntime;
...@@ -1110,12 +1112,19 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream, ...@@ -1110,12 +1112,19 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,
if (ret < 0 && ret != -ENOTSUPP) { if (ret < 0 && ret != -ENOTSUPP) {
dev_err(dai->dev, "Failed to set sdw stream on %s\n", dev_err(dai->dev, "Failed to set sdw stream on %s\n",
codec_dai->name); codec_dai->name);
sdw_release_stream(sruntime); goto err_set_stream;
return ret;
} }
} }
return 0; return 0;
err_set_stream:
sdw_release_stream(sruntime);
err_alloc:
pm_runtime_mark_last_busy(ctrl->dev);
pm_runtime_put_autosuspend(ctrl->dev);
return ret;
} }
static void qcom_swrm_shutdown(struct snd_pcm_substream *substream, static void qcom_swrm_shutdown(struct snd_pcm_substream *substream,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册