[PATCH 1/6] clk: mediatek: fix unregister function in mtk_clk_register_dividers cleanup

Chen-Yu Tsai posted 6 patches 1 year, 12 months ago
[PATCH 1/6] clk: mediatek: fix unregister function in mtk_clk_register_dividers cleanup
Posted by Chen-Yu Tsai 1 year, 12 months ago
When the cleanup paths for the various clk register APIs in the MediaTek
clk library were added, the one in the dividers type used the wrong type
of unregister function. This would result in incorrect dereferencing of
the clk pointer and freeing of invalid pointers.

Fix this by switching to the correct type of clk unregistration call.

Fixes: 3c3ba2ab0226 ("clk: mediatek: mtk: Implement error handling in register APIs")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
 drivers/clk/mediatek/clk-mtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 3a8875b6c37f..174d0645be38 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -393,7 +393,7 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num,
 		if (IS_ERR_OR_NULL(clk_data->hws[mcd->id]))
 			continue;
 
-		mtk_clk_unregister_composite(clk_data->hws[mcd->id]);
+		clk_hw_unregister_divider(clk_data->hws[mcd->id]);
 		clk_data->hws[mcd->id] = ERR_PTR(-ENOENT);
 	}
 
-- 
2.37.3.998.g577e59143f-goog
Re: [PATCH 1/6] clk: mediatek: fix unregister function in mtk_clk_register_dividers cleanup
Posted by AngeloGioacchino Del Regno 1 year, 12 months ago
Il 26/09/22 12:25, Chen-Yu Tsai ha scritto:
> When the cleanup paths for the various clk register APIs in the MediaTek
> clk library were added, the one in the dividers type used the wrong type
> of unregister function. This would result in incorrect dereferencing of
> the clk pointer and freeing of invalid pointers.
> 
> Fix this by switching to the correct type of clk unregistration call.
> 
> Fixes: 3c3ba2ab0226 ("clk: mediatek: mtk: Implement error handling in register APIs")
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>