瀏覽代碼

clk: rockchip: Fix error return in phase clock registration

The newly added clock notifier may return an error code but so far the
error output in the function would only return an error pointer from
registering the clock.

So when the clock notifier fails the clock would be unregistered but the
return would still be the clock pointer which could then not be
dereferenced correctly. So fix the error handling to prevent that.

Fixes: 60cf09e45fbc ("clk: rockchip: Restore the clock phase after the rate was changed")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Shawn Lin 7 年之前
父節點
當前提交
0d92d1802c
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      drivers/clk/rockchip/clk-mmc-phase.c

+ 4 - 2
drivers/clk/rockchip/clk-mmc-phase.c

@@ -223,8 +223,10 @@ struct clk *rockchip_clk_register_mmc(const char *name,
 	mmc_clock->shift = shift;
 	mmc_clock->shift = shift;
 
 
 	clk = clk_register(NULL, &mmc_clock->hw);
 	clk = clk_register(NULL, &mmc_clock->hw);
-	if (IS_ERR(clk))
+	if (IS_ERR(clk)) {
+		ret = PTR_ERR(clk);
 		goto err_register;
 		goto err_register;
+	}
 
 
 	mmc_clock->clk_rate_change_nb.notifier_call =
 	mmc_clock->clk_rate_change_nb.notifier_call =
 				&rockchip_mmc_clk_rate_notify;
 				&rockchip_mmc_clk_rate_notify;
@@ -237,5 +239,5 @@ err_notifier:
 	clk_unregister(clk);
 	clk_unregister(clk);
 err_register:
 err_register:
 	kfree(mmc_clock);
 	kfree(mmc_clock);
-	return clk;
+	return ERR_PTR(ret);
 }
 }