Message ID | 20221229092946.4162345-1-yangyingliang@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | clk: mediatek: clk-pllfh: fix missing of_node_put() in fhctl_parse_dt() | expand |
Quoting Yang Yingliang (2022-12-29 01:29:46) > The device_node pointer returned by of_find_compatible_node() with > refcount incremented, when finish using it, the refcount need be > decreased. > > Fixes: d7964de8a8ea ("clk: mediatek: Add new clock driver to handle FHCTL hardware") > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> > --- > drivers/clk/mediatek/clk-pllfh.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/mediatek/clk-pllfh.c b/drivers/clk/mediatek/clk-pllfh.c > index f48780bec507..bc2b30a55f60 100644 > --- a/drivers/clk/mediatek/clk-pllfh.c > +++ b/drivers/clk/mediatek/clk-pllfh.c > @@ -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 out_node_put; This leaks the of_iomap() mapping still. I folded this in. ---8<-- diff --git a/drivers/clk/mediatek/clk-pllfh.c b/drivers/clk/mediatek/clk-pllfh.c index bc2b30a55f60..f135b32c6dbe 100644 --- a/drivers/clk/mediatek/clk-pllfh.c +++ b/drivers/clk/mediatek/clk-pllfh.c @@ -81,7 +81,7 @@ void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs, num_clocks = of_clk_get_parent_count(node); if (!num_clocks) { pr_err("%s(): failed to get clocks property\n", __func__); - goto out_node_put; + goto err; } for (i = 0; i < num_clocks; i++) { @@ -105,6 +105,10 @@ void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs, 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)
diff --git a/drivers/clk/mediatek/clk-pllfh.c b/drivers/clk/mediatek/clk-pllfh.c index f48780bec507..bc2b30a55f60 100644 --- a/drivers/clk/mediatek/clk-pllfh.c +++ b/drivers/clk/mediatek/clk-pllfh.c @@ -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 out_node_put; } for (i = 0; i < num_clocks; i++) { @@ -102,6 +102,9 @@ 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); } static void pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data)
The device_node pointer returned by of_find_compatible_node() with refcount incremented, when finish using it, the refcount need be decreased. Fixes: d7964de8a8ea ("clk: mediatek: Add new clock driver to handle FHCTL hardware") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/clk/mediatek/clk-pllfh.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)