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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230727053156.13587-2-claudiu.beznea@tuxon.dev>
Date:   Thu, 27 Jul 2023 08:31:15 +0300
From:   Claudiu Beznea <claudiu.beznea@...on.dev>
To:     mturquette@...libre.com, sboyd@...nel.org,
        nicolas.ferre@...rochip.com, alexandre.belloni@...tlin.com,
        mripard@...nel.org
Cc:     linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org, varshini.rajendran@...rochip.com,
        Claudiu Beznea <claudiu.beznea@...on.dev>
Subject: [PATCH 01/42] clk: at91: sama7g5: check __clk_get_hw() argument for errors

__clk_get_hw() argument in sama7g5 is obtained using
of_clk_get_by_name() which might return error. Passing an error casted
pointer to __clk_get_hw() may lead to crashes. Thus, check the pointer
for errors before passing it to __clk_get_hw().

Fixes: de3383e993a5 ("clk: at91: sama7g5: switch to parent_hw and parent_data")
Signed-off-by: Claudiu Beznea <claudiu.beznea@...on.dev>
---
 drivers/clk/at91/sama7g5.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c
index 91b5c6f14819..16e458be8304 100644
--- a/drivers/clk/at91/sama7g5.c
+++ b/drivers/clk/at91/sama7g5.c
@@ -988,14 +988,27 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
 	struct clk_hw *td_slck_hw, *md_slck_hw;
 	static struct clk_parent_data parent_data;
 	struct clk_hw *parent_hws[10];
+	struct clk *clk;
 	bool bypass;
 	int i, j;
 
-	td_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "td_slck"));
-	md_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "md_slck"));
-	main_xtal_hw = __clk_get_hw(of_clk_get_by_name(np, main_xtal_name));
-
-	if (!td_slck_hw || !md_slck_hw || !main_xtal_hw)
+	clk = of_clk_get_by_name(np, "td_slck");
+	if (IS_ERR(clk))
+		return;
+	td_slck_hw = __clk_get_hw(clk);
+	if (!td_slck_hw)
+		return;
+	clk = of_clk_get_by_name(np, "md_slck");
+	if (IS_ERR(clk))
+		return;
+	md_slck_hw = __clk_get_hw(clk);
+	if (!md_slck_hw)
+		return;
+	clk = of_clk_get_by_name(np, main_xtal_name);
+	if (IS_ERR(clk))
+		return;
+	main_xtal_hw = __clk_get_hw(clk);
+	if (!main_xtal_hw)
 		return;
 
 	regmap = device_node_to_regmap(np);
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ