Commit a20a40a8 authored by Dinghao Liu's avatar Dinghao Liu Committed by Geert Uytterhoeven

clk: renesas: rcar-usb2-clock-sel: Fix error handling in .probe()

The error handling paths after pm_runtime_get_sync() have no refcount
decrement, which leads to refcount leak.
Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20210415073338.22287-1-dinghao.liu@zju.edu.cn
[geert: Remove now unused variable priv]
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
parent 16927401
...@@ -128,10 +128,8 @@ static int rcar_usb2_clock_sel_resume(struct device *dev) ...@@ -128,10 +128,8 @@ static int rcar_usb2_clock_sel_resume(struct device *dev)
static int rcar_usb2_clock_sel_remove(struct platform_device *pdev) static int rcar_usb2_clock_sel_remove(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct usb2_clock_sel_priv *priv = platform_get_drvdata(pdev);
of_clk_del_provider(dev->of_node); of_clk_del_provider(dev->of_node);
clk_hw_unregister(&priv->hw);
pm_runtime_put(dev); pm_runtime_put(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
...@@ -164,9 +162,6 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev) ...@@ -164,9 +162,6 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
if (IS_ERR(priv->rsts)) if (IS_ERR(priv->rsts))
return PTR_ERR(priv->rsts); return PTR_ERR(priv->rsts);
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
clk = devm_clk_get(dev, "usb_extal"); clk = devm_clk_get(dev, "usb_extal");
if (!IS_ERR(clk) && !clk_prepare_enable(clk)) { if (!IS_ERR(clk) && !clk_prepare_enable(clk)) {
priv->extal = !!clk_get_rate(clk); priv->extal = !!clk_get_rate(clk);
...@@ -183,6 +178,8 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev) ...@@ -183,6 +178,8 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
dev_set_drvdata(dev, priv); dev_set_drvdata(dev, priv);
...@@ -190,11 +187,20 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev) ...@@ -190,11 +187,20 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
init.ops = &usb2_clock_sel_clock_ops; init.ops = &usb2_clock_sel_clock_ops;
priv->hw.init = &init; priv->hw.init = &init;
clk = clk_register(NULL, &priv->hw); ret = devm_clk_hw_register(NULL, &priv->hw);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); goto pm_put;
ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &priv->hw);
if (ret)
goto pm_put;
return 0;
return of_clk_add_hw_provider(np, of_clk_hw_simple_get, &priv->hw); pm_put:
pm_runtime_put(dev);
pm_runtime_disable(dev);
return ret;
} }
static const struct dev_pm_ops rcar_usb2_clock_sel_pm_ops = { static const struct dev_pm_ops rcar_usb2_clock_sel_pm_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment