ASoC: ti: j721e-evm: Fix refcount leak in j721e_soc_probe_*
[ Upstream commit a34840c4eb3278a7c29c9c57a65ce7541c66f9f2 ]
of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not needed anymore.
Add missing of_node_put() to avoid refcount leak.
Fixes: 6748d05590 ("ASoC: ti: Add custom machine driver for j721e EVM (CPB and IVI)")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220512111331.44774-1-linmq006@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cf31d1ef38
commit
2a3966b950
@@ -634,17 +634,18 @@ static int j721e_soc_probe_cpb(struct j721e_priv *priv, int *link_idx,
|
|||||||
codec_node = of_parse_phandle(node, "ti,cpb-codec", 0);
|
codec_node = of_parse_phandle(node, "ti,cpb-codec", 0);
|
||||||
if (!codec_node) {
|
if (!codec_node) {
|
||||||
dev_err(priv->dev, "CPB codec node is not provided\n");
|
dev_err(priv->dev, "CPB codec node is not provided\n");
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto put_dai_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
domain = &priv->audio_domains[J721E_AUDIO_DOMAIN_CPB];
|
domain = &priv->audio_domains[J721E_AUDIO_DOMAIN_CPB];
|
||||||
ret = j721e_get_clocks(priv->dev, &domain->codec, "cpb-codec-scki");
|
ret = j721e_get_clocks(priv->dev, &domain->codec, "cpb-codec-scki");
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto put_codec_node;
|
||||||
|
|
||||||
ret = j721e_get_clocks(priv->dev, &domain->mcasp, "cpb-mcasp-auxclk");
|
ret = j721e_get_clocks(priv->dev, &domain->mcasp, "cpb-mcasp-auxclk");
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto put_codec_node;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Common Processor Board, two links
|
* Common Processor Board, two links
|
||||||
@@ -654,8 +655,10 @@ static int j721e_soc_probe_cpb(struct j721e_priv *priv, int *link_idx,
|
|||||||
comp_count = 6;
|
comp_count = 6;
|
||||||
compnent = devm_kzalloc(priv->dev, comp_count * sizeof(*compnent),
|
compnent = devm_kzalloc(priv->dev, comp_count * sizeof(*compnent),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!compnent)
|
if (!compnent) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto put_codec_node;
|
||||||
|
}
|
||||||
|
|
||||||
comp_idx = 0;
|
comp_idx = 0;
|
||||||
priv->dai_links[*link_idx].cpus = &compnent[comp_idx++];
|
priv->dai_links[*link_idx].cpus = &compnent[comp_idx++];
|
||||||
@@ -706,6 +709,12 @@ static int j721e_soc_probe_cpb(struct j721e_priv *priv, int *link_idx,
|
|||||||
(*conf_idx)++;
|
(*conf_idx)++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
put_codec_node:
|
||||||
|
of_node_put(codec_node);
|
||||||
|
put_dai_node:
|
||||||
|
of_node_put(dai_node);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int j721e_soc_probe_ivi(struct j721e_priv *priv, int *link_idx,
|
static int j721e_soc_probe_ivi(struct j721e_priv *priv, int *link_idx,
|
||||||
@@ -730,23 +739,25 @@ static int j721e_soc_probe_ivi(struct j721e_priv *priv, int *link_idx,
|
|||||||
codeca_node = of_parse_phandle(node, "ti,ivi-codec-a", 0);
|
codeca_node = of_parse_phandle(node, "ti,ivi-codec-a", 0);
|
||||||
if (!codeca_node) {
|
if (!codeca_node) {
|
||||||
dev_err(priv->dev, "IVI codec-a node is not provided\n");
|
dev_err(priv->dev, "IVI codec-a node is not provided\n");
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto put_dai_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
codecb_node = of_parse_phandle(node, "ti,ivi-codec-b", 0);
|
codecb_node = of_parse_phandle(node, "ti,ivi-codec-b", 0);
|
||||||
if (!codecb_node) {
|
if (!codecb_node) {
|
||||||
dev_warn(priv->dev, "IVI codec-b node is not provided\n");
|
dev_warn(priv->dev, "IVI codec-b node is not provided\n");
|
||||||
return 0;
|
ret = 0;
|
||||||
|
goto put_codeca_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
domain = &priv->audio_domains[J721E_AUDIO_DOMAIN_IVI];
|
domain = &priv->audio_domains[J721E_AUDIO_DOMAIN_IVI];
|
||||||
ret = j721e_get_clocks(priv->dev, &domain->codec, "ivi-codec-scki");
|
ret = j721e_get_clocks(priv->dev, &domain->codec, "ivi-codec-scki");
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto put_codecb_node;
|
||||||
|
|
||||||
ret = j721e_get_clocks(priv->dev, &domain->mcasp, "ivi-mcasp-auxclk");
|
ret = j721e_get_clocks(priv->dev, &domain->mcasp, "ivi-mcasp-auxclk");
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto put_codecb_node;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IVI extension, two links
|
* IVI extension, two links
|
||||||
@@ -758,8 +769,10 @@ static int j721e_soc_probe_ivi(struct j721e_priv *priv, int *link_idx,
|
|||||||
comp_count = 8;
|
comp_count = 8;
|
||||||
compnent = devm_kzalloc(priv->dev, comp_count * sizeof(*compnent),
|
compnent = devm_kzalloc(priv->dev, comp_count * sizeof(*compnent),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!compnent)
|
if (!compnent) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto put_codecb_node;
|
||||||
|
}
|
||||||
|
|
||||||
comp_idx = 0;
|
comp_idx = 0;
|
||||||
priv->dai_links[*link_idx].cpus = &compnent[comp_idx++];
|
priv->dai_links[*link_idx].cpus = &compnent[comp_idx++];
|
||||||
@@ -820,6 +833,15 @@ static int j721e_soc_probe_ivi(struct j721e_priv *priv, int *link_idx,
|
|||||||
(*conf_idx)++;
|
(*conf_idx)++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
put_codecb_node:
|
||||||
|
of_node_put(codecb_node);
|
||||||
|
put_codeca_node:
|
||||||
|
of_node_put(codeca_node);
|
||||||
|
put_dai_node:
|
||||||
|
of_node_put(dai_node);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int j721e_soc_probe(struct platform_device *pdev)
|
static int j721e_soc_probe(struct platform_device *pdev)
|
||||||
|
|||||||
Reference in New Issue
Block a user