diff mbox

clk: imx: pllv2: avoid using uninitialized values

Message ID 20180117150256.7430-1-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Stach Jan. 17, 2018, 3:02 p.m. UTC
Forward the errors returned by __clk_pllv2_set_rate() in the recalc rate
function, to avoid using uninitialized values for the rate calculation.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-pllv2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Fabio Estevam Jan. 17, 2018, 6:52 p.m. UTC | #1
On Wed, Jan 17, 2018 at 1:02 PM, Lucas Stach <l.stach@pengutronix.de> wrote:
> Forward the errors returned by __clk_pllv2_set_rate() in the recalc rate
> function, to avoid using uninitialized values for the rate calculation.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>

Thanks
Stephen Boyd March 16, 2018, 10:41 p.m. UTC | #2
Quoting Lucas Stach (2018-01-17 07:02:56)
> Forward the errors returned by __clk_pllv2_set_rate() in the recalc rate
> function, to avoid using uninitialized values for the rate calculation.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---

Applied to clk-next
diff mbox

Patch

diff --git a/drivers/clk/imx/clk-pllv2.c b/drivers/clk/imx/clk-pllv2.c
index 85b5cbe9744c..eeba3cb14e2d 100644
--- a/drivers/clk/imx/clk-pllv2.c
+++ b/drivers/clk/imx/clk-pllv2.c
@@ -182,8 +182,12 @@  static long clk_pllv2_round_rate(struct clk_hw *hw, unsigned long rate,
 		unsigned long *prate)
 {
 	u32 dp_op, dp_mfd, dp_mfn;
+	int ret;
+
+	ret = __clk_pllv2_set_rate(rate, *prate, &dp_op, &dp_mfd, &dp_mfn);
+	if (ret)
+		return ret;
 
-	__clk_pllv2_set_rate(rate, *prate, &dp_op, &dp_mfd, &dp_mfn);
 	return __clk_pllv2_recalc_rate(*prate, MXC_PLL_DP_CTL_DPDCK0_2_EN,
 			dp_op, dp_mfd, dp_mfn);
 }