[PATCH 2/3] ASoC: soc.h: fixup return timing for snd_soc_fixup_dai_links_platform_name()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Mon Mar 22 03:48:40 CET 2021
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
Current snd_soc_fixup_dai_links_platform_name() creates name first (A),
and checks setup target pointer (B), and set it (C).
We should check target pointer first IMO.
This patch exchange the order to (B) -> (A) -> (C).
int snd_soc_fixup_dai_links_platform_name(...)
{
...
/* set platform name for each dailink */
for_each_card_prelinks(card, i, dai_link) {
(A) name = devm_kstrdup(...);
if (!name)
return -ENOMEM;
(B) if (!dai_link->platforms)
return -EINVAL;
/* only single platform is supported for now */
(C) dai_link->platforms->name = name;
}
return 0;
}
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
include/sound/soc.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index e4161071f300..200815ca4112 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1280,13 +1280,13 @@ int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
/* set platform name for each dailink */
for_each_card_prelinks(card, i, dai_link) {
+ if (!dai_link->platforms)
+ return -EINVAL;
+
name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
if (!name)
return -ENOMEM;
- if (!dai_link->platforms)
- return -EINVAL;
-
/* only single platform is supported for now */
dai_link->platforms->name = name;
}
--
2.25.1
More information about the Alsa-devel
mailing list