lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210318144230.3438009-1-m.tretter@pengutronix.de>
Date:   Thu, 18 Mar 2021 15:42:30 +0100
From:   Michael Tretter <m.tretter@...gutronix.de>
To:     colin.king@...onical.com, sboyd@...nel.org,
        linux-clk@...r.kernel.org
Cc:     m.tretter@...gutronix.de, mturquette@...libre.com,
        michal.simek@...inx.com, linux-arm-kernel@...ts.infradead.org,
        kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] clk: xilinx: vcu: rewrite and fix xvcu_clk_hw_unregister_leaf

The xvcu_clk_hw_unregister_leaf function was missing a check if the
clock mux exits before unregistering the clock mux.

Fix the error by rewriting the entire function. The function now first
finds all clocks that are part of the output clock and afterwards
unregisters all found clocks. This avoids mixing the unregister calls
with get_parent calls and makes the code more readable.

Reported-by: Colin Ian King <colin.king@...onical.com>
Fixes: 9c789deea206 ("soc: xilinx: vcu: implement clock provider for output clocks")
Signed-off-by: Michael Tretter <m.tretter@...gutronix.de>
---
Hi,

This is a cleanup and rewrite of the function following the issue
reported by Colin [0]. Hopefully, this is going to clear up the
confusion and makes the code easier to follow.

[0] https://lore.kernel.org/kernel-janitors/20210211095700.158960-1-colin.king@canonical.com/

Michael
---
 drivers/clk/xilinx/xlnx_vcu.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/clk/xilinx/xlnx_vcu.c b/drivers/clk/xilinx/xlnx_vcu.c
index d66b1315114e..266ee797fdb7 100644
--- a/drivers/clk/xilinx/xlnx_vcu.c
+++ b/drivers/clk/xilinx/xlnx_vcu.c
@@ -499,23 +499,22 @@ static struct clk_hw *xvcu_clk_hw_register_leaf(struct device *dev,
 static void xvcu_clk_hw_unregister_leaf(struct clk_hw *hw)
 {
 	struct clk_hw *gate = hw;
-	struct clk_hw *divider;
-	struct clk_hw *mux;
-
-	if (!gate)
-		return;
-
-	divider = clk_hw_get_parent(gate);
-	clk_hw_unregister_gate(gate);
-	if (!divider)
-		return;
-
-	mux = clk_hw_get_parent(divider);
-	clk_hw_unregister_mux(mux);
-	if (!divider)
-		return;
+	struct clk_hw *divider = NULL;
+	struct clk_hw *mux = NULL;
 
-	clk_hw_unregister_divider(divider);
+	/* Get all clocks of this output clock */
+	if (gate)
+		divider = clk_hw_get_parent(gate);
+	if (divider)
+		mux = clk_hw_get_parent(divider);
+
+	/* Unregister clocks of this output clock if they have been found */
+	if (gate)
+		clk_hw_unregister_gate(gate);
+	if (divider)
+		clk_hw_unregister_divider(divider);
+	if (mux)
+		clk_hw_unregister_mux(mux);
 }
 
 static int xvcu_register_clock_provider(struct xvcu_device *xvcu)
-- 
2.29.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ