blob: c27974754b1f7a248e00021fece1f51f4e9ca78b [file] [log] [blame]
From 3b41c684b442bdacfb303c3ffe2ef0e417a73dec Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <>
Date: Wed, 22 Jan 2020 20:07:52 +0100
Subject: [PATCH] ASoC: topology: fix soc_tplg_fe_link_create() - link->dobj
initialization order
commit 8ce1cbd6ce0b1bda0c980c64fee4c1e1378355f1 upstream.
The code which checks the return value for snd_soc_add_dai_link() call
in soc_tplg_fe_link_create() moved the snd_soc_add_dai_link() call before
link->dobj members initialization.
While it does not affect the latest kernels, the old soc-core.c code
in the stable kernels is affected. The snd_soc_add_dai_link() function uses
the link->dobj.type member to check, if the link structure is valid.
Reorder the link->dobj initialization to make things work again.
It's harmless for the recent code (and the structure should be properly
initialized before other calls anyway).
The problem is in stable linux-5.4.y since version 5.4.11 when the
upstream commit 76d270364932 was applied.
Fixes: 76d270364932 ("ASoC: topology: Check return value for snd_soc_add_dai_link()")
Cc: Dragos Tarcatu <>
Cc: Pierre-Louis Bossart <>
Cc: Ranjani Sridharan <>
Cc: Mark Brown <>
Cc: <>
Signed-off-by: Jaroslav Kysela <>
Signed-off-by: Mark Brown <>
Signed-off-by: Paul Gortmaker <>
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 6fa9b82a5fea..85a23b0f99bb 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1885,6 +1885,10 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
if (link == NULL)
return -ENOMEM;
+ link->dobj.index = tplg->index;
+ link->dobj.ops = tplg->ops;
+ link->dobj.type = SND_SOC_DOBJ_DAI_LINK;
if (strlen(pcm->pcm_name)) {
link->name = kstrdup(pcm->pcm_name, GFP_KERNEL);
link->stream_name = kstrdup(pcm->pcm_name, GFP_KERNEL);
@@ -1919,9 +1923,6 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
goto err;
- link->dobj.index = tplg->index;
- link->dobj.ops = tplg->ops;
- link->dobj.type = SND_SOC_DOBJ_DAI_LINK;
list_add(&link->dobj.list, &tplg->comp->dobj_list);
return 0;