Skip to content

Commit 99e09b9

Browse files
krzkvinodkoul
authored andcommitted
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: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20230517163736.997553-1-krzysztof.kozlowski@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 700581e commit 99e09b9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/soundwire/qcom.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,10 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,
10991099
}
11001100

11011101
sruntime = sdw_alloc_stream(dai->name);
1102-
if (!sruntime)
1103-
return -ENOMEM;
1102+
if (!sruntime) {
1103+
ret = -ENOMEM;
1104+
goto err_alloc;
1105+
}
11041106

11051107
ctrl->sruntime[dai->id] = sruntime;
11061108

@@ -1110,12 +1112,19 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,
11101112
if (ret < 0 && ret != -ENOTSUPP) {
11111113
dev_err(dai->dev, "Failed to set sdw stream on %s\n",
11121114
codec_dai->name);
1113-
sdw_release_stream(sruntime);
1114-
return ret;
1115+
goto err_set_stream;
11151116
}
11161117
}
11171118

11181119
return 0;
1120+
1121+
err_set_stream:
1122+
sdw_release_stream(sruntime);
1123+
err_alloc:
1124+
pm_runtime_mark_last_busy(ctrl->dev);
1125+
pm_runtime_put_autosuspend(ctrl->dev);
1126+
1127+
return ret;
11191128
}
11201129

11211130
static void qcom_swrm_shutdown(struct snd_pcm_substream *substream,

0 commit comments

Comments
 (0)