ASoc: audio-graph-card2: Fix refcount leak bug in __graph_get_type()
We should call of_node_put() for the reference before its replacement
as it returned by of_get_parent() which has increased the refcount.
Besides, we should also call of_node_put() before return.
Fixes: c8c74939f7
("ASoC: audio-graph-card2: add Multi CPU/Codec support")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20220713071200.366729-1-windhl@126.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
73acfba792
commit
eda26893da
@ -229,7 +229,8 @@ enum graph_type {
|
|||||||
|
|
||||||
static enum graph_type __graph_get_type(struct device_node *lnk)
|
static enum graph_type __graph_get_type(struct device_node *lnk)
|
||||||
{
|
{
|
||||||
struct device_node *np;
|
struct device_node *np, *parent_np;
|
||||||
|
enum graph_type ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* target {
|
* target {
|
||||||
@ -240,19 +241,33 @@ static enum graph_type __graph_get_type(struct device_node *lnk)
|
|||||||
* };
|
* };
|
||||||
*/
|
*/
|
||||||
np = of_get_parent(lnk);
|
np = of_get_parent(lnk);
|
||||||
if (of_node_name_eq(np, "ports"))
|
if (of_node_name_eq(np, "ports")) {
|
||||||
np = of_get_parent(np);
|
parent_np = of_get_parent(np);
|
||||||
|
of_node_put(np);
|
||||||
|
np = parent_np;
|
||||||
|
}
|
||||||
|
|
||||||
if (of_node_name_eq(np, GRAPH_NODENAME_MULTI))
|
if (of_node_name_eq(np, GRAPH_NODENAME_MULTI)) {
|
||||||
return GRAPH_MULTI;
|
ret = GRAPH_MULTI;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
if (of_node_name_eq(np, GRAPH_NODENAME_DPCM))
|
if (of_node_name_eq(np, GRAPH_NODENAME_DPCM)) {
|
||||||
return GRAPH_DPCM;
|
ret = GRAPH_DPCM;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
if (of_node_name_eq(np, GRAPH_NODENAME_C2C))
|
if (of_node_name_eq(np, GRAPH_NODENAME_C2C)) {
|
||||||
return GRAPH_C2C;
|
ret = GRAPH_C2C;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = GRAPH_NORMAL;
|
||||||
|
|
||||||
|
out_put:
|
||||||
|
of_node_put(np);
|
||||||
|
return ret;
|
||||||
|
|
||||||
return GRAPH_NORMAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum graph_type graph_get_type(struct asoc_simple_priv *priv,
|
static enum graph_type graph_get_type(struct asoc_simple_priv *priv,
|
||||||
|
Loading…
Reference in New Issue
Block a user