Skip to content

Commit

Permalink
ASoC: simple-card: fix an use-after-free in simple_dai_link_of_dpcm()
Browse files Browse the repository at this point in the history
The node variable is still being used after the of_node_put() call,
which may result in use-after-free.

Fixes: cfc652a ("ASoC: simple-card: tidyup prefix for snd_soc_codec_conf")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Wen Yang <[email protected]>
Acked-by: Kuninori Morimoto <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
taskset authored and broonie committed Jul 10, 2019
1 parent 794fcee commit 724808a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions sound/soc/generic/simple-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,

li->link++;

of_node_put(node);

/* For single DAI link & old style of DT node */
if (is_top)
prefix = PREFIX;
Expand All @@ -147,17 +145,17 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,

ret = asoc_simple_parse_cpu(np, dai_link, &is_single_links);
if (ret)
return ret;
goto out_put_node;

ret = asoc_simple_parse_clk_cpu(dev, np, dai_link, dai);
if (ret < 0)
return ret;
goto out_put_node;

ret = asoc_simple_set_dailink_name(dev, dai_link,
"fe.%s",
cpus->dai_name);
if (ret < 0)
return ret;
goto out_put_node;

asoc_simple_canonicalize_cpu(dai_link, is_single_links);
} else {
Expand All @@ -180,17 +178,17 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,

ret = asoc_simple_parse_codec(np, dai_link);
if (ret < 0)
return ret;
goto out_put_node;

ret = asoc_simple_parse_clk_codec(dev, np, dai_link, dai);
if (ret < 0)
return ret;
goto out_put_node;

ret = asoc_simple_set_dailink_name(dev, dai_link,
"be.%s",
codecs->dai_name);
if (ret < 0)
return ret;
goto out_put_node;

/* check "prefix" from top node */
snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node,
Expand All @@ -208,19 +206,21 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,

ret = asoc_simple_parse_tdm(np, dai);
if (ret)
return ret;
goto out_put_node;

ret = asoc_simple_parse_daifmt(dev, node, codec,
prefix, &dai_link->dai_fmt);
if (ret < 0)
return ret;
goto out_put_node;

dai_link->dpcm_playback = 1;
dai_link->dpcm_capture = 1;
dai_link->ops = &simple_ops;
dai_link->init = asoc_simple_dai_init;

return 0;
out_put_node:
of_node_put(node);
return ret;
}

static int simple_dai_link_of(struct asoc_simple_priv *priv,
Expand Down

0 comments on commit 724808a

Please sign in to comment.