ASoC: simple-card-utils: fixup dlc->xxx handling for error case
Kuninori Morimoto
maintainerPATCH v2 1/1 ASoC: simple-card-utils: fixup dlc->xxx handling for error case
Current graph_util_parse_dai() has 2 issue for dlc->xxx handling.
1) dlc->xxx might be filled if snd_soc_get_dai_via_args() (A) works. In such case it will fill dlc->xxx first (B), and detect error after that (C). We need to fill dlc->xxx in success case only.
(A) dai = snd_soc_get_dai_via_args(&args);
if (dai) {
ret = -ENOMEM; ^ dlc->of_node = ...
(B) dlc->dai_name = ...
v dlc->dai_args = ...
(C) if (!dlc->dai_args)
goto end; ... }
2) graph_util_parse_dai() itself has 2 patterns (X)(Y) to fill dlc->xxx. Both case, we need to call of_node_put(node) (Z) in error case, but we are calling it only in (Y) case.
int graph_util_parse_dai(...)
{
...
dai = snd_soc_get_dai_via_args(&args);
if (dai) {
...
^ dlc->of_node = ...
(X) dlc->dai_name = ...
v dlc->dai_args = ...
...
}
...
(Y) ret = snd_soc_get_dlc(&args, dlc);
if (ret < 0) {
(Z) of_node_put(node);
...
}
...
}This patch fixup both case. Make it easy to understand, update lavel "end" to "err", too.
---
v1 -> v2
- rebased to latest asoc/for-6.16
sound/soc/generic/simple-card-utils.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
sound/soc/generic/simple-card-utils.c +14 -9
@@ -1119,12 +1119,16 @@ int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep, args.np = ep; dai =snd_soc_get_dai_via_args (&args);if (dai) { +const char *dai_name =snd_soc_dai_name_get (dai); +const struct of_phandle_args *dai_args =snd_soc_copy_dai_args (dev, &args); + ret = -ENOMEM ; +if (!dai_args) + goto err; + dlc->of_node = node; - dlc->dai_name =snd_soc_dai_name_get (dai); - dlc->dai_args =snd_soc_copy_dai_args (dev, &args); -if (!dlc->dai_args) - goto end; + dlc->dai_name = dai_name; + dlc->dai_args = dai_args; goto parse_dai_end; }
@@ -1154,16 +1158,17 @@ int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep,* if he unbinded CPU or Codec. */ ret =snd_soc_get_dlc (&args, dlc); -if (ret <0 ) { -of_node_put (node); - goto end; - } +if (ret <0 ) + goto err; parse_dai_end:if (is_single_link) *is_single_link =of_graph_get_endpoint_count (node) ==1 ; ret =0 ; -end: +err: +if (ret <0 ) +of_node_put (node); +return simple_ret (priv, ret); }EXPORT_SYMBOL_GPL (graph_util_parse_dai);
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 13 lines · Kuninori Morimoto
Current
graph_util_parse_dai()has 2 issue fordlc->xxxhandling.1)
dlc->xxxmight be filled ifsnd_soc_get_dai_via_args()(A) works. In such case it will filldlc->xxxfirst (B), and detect error after that (C). We need to filldlc->xxxin success case only.(A) dai = snd_soc_get_dai_via_args(&args); if (dai) { ret = -ENOMEM;^
dlc->of_node= ...
(B)dlc->dai_name= ...
vdlc->dai_args= ...
(C) if (!dlc->dai_args)
Quoted 5 lines
goto end; ... }[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: simple-card-utils: fixup dlc->xxx handling for error case
commit: 2b4ce994afca0690ab79b7860045e6883e8706db
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark