ASoC: soc.h: fixup return timing for snd_soc_fixup_dai_links_platform_name()

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@renesas.com>
Link: https://lore.kernel.org/r/8735wnaoon.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2021-03-22 11:48:40 +09:00 committed by Mark Brown
parent 4da40cb995
commit 4a50724eb0
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 3 additions and 3 deletions

View File

@ -1280,13 +1280,13 @@ int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
/* set platform name for each dailink */ /* set platform name for each dailink */
for_each_card_prelinks(card, i, dai_link) { for_each_card_prelinks(card, i, dai_link) {
if (!dai_link->platforms)
return -EINVAL;
name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL); name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
if (!name) if (!name)
return -ENOMEM; return -ENOMEM;
if (!dai_link->platforms)
return -EINVAL;
/* only single platform is supported for now */ /* only single platform is supported for now */
dai_link->platforms->name = name; dai_link->platforms->name = name;
} }