Skip to content

Commit

Permalink
clk: mediatek: clk-pllfh: fix missing of_node_put() in fhctl_parse_dt()
Browse files Browse the repository at this point in the history
[ Upstream commit f1d97a3 ]

The device_node pointer returned by of_find_compatible_node() with
refcount incremented, when finish using it, the refcount need be
decreased.

Fixes: d7964de ("clk: mediatek: Add new clock driver to handle FHCTL hardware")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221229092946.4162345-1-yangyingliang@huawei.com
[sboyd@kernel.org: Also unmap on error]
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yang Yingliang authored and gregkh committed May 11, 2023
1 parent f1a0bad commit 934124e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/clk/mediatek/clk-pllfh.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs,
base = of_iomap(node, 0);
if (!base) {
pr_err("%s(): ioremap failed\n", __func__);
return;
goto out_node_put;
}

num_clocks = of_clk_get_parent_count(node);
if (!num_clocks) {
pr_err("%s(): failed to get clocks property\n", __func__);
return;
goto err;
}

for (i = 0; i < num_clocks; i++) {
Expand All @@ -102,6 +102,13 @@ void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs,
pllfh->state.ssc_rate = ssc_rate;
pllfh->state.base = base;
}

out_node_put:
of_node_put(node);
return;
err:
iounmap(base);
goto out_node_put;
}

static void pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data)
Expand Down

0 comments on commit 934124e

Please sign in to comment.