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: <422c6249-31ac-410e-911d-ec25aeee126a@web.de>
Date: Sun, 24 Dec 2023 17:36:57 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: linux-omap@...r.kernel.org, linux-clk@...r.kernel.org,
 kernel-janitors@...r.kernel.org,
 Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
 Claudiu Beznea <claudiu.beznea@...on.dev>,
 Michael Turquette <mturquette@...libre.com>, Rob Herring <robh@...nel.org>,
 Stephen Boyd <sboyd@...nel.org>, Tero Kristo <kristo@...nel.org>,
 Tony Lindgren <tony@...mide.com>
Cc: LKML <linux-kernel@...r.kernel.org>, cocci@...ia.fr
Subject: [PATCH 01/10] clk: ti: Less function calls in of_omap2_apll_setup()
 after error detection

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sun, 24 Dec 2023 11:15:27 +0100

The kfree() function was called in up to three cases by
the of_omap2_apll_setup() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.

* Split a condition check.

* Adjust jump targets.

* Delete three initialisations which became unnecessary
  with this refactoring.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/clk/ti/apll.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c
index 93183287c58d..929c021f0cdb 100644
--- a/drivers/clk/ti/apll.c
+++ b/drivers/clk/ti/apll.c
@@ -338,21 +338,25 @@ static const struct clk_hw_omap_ops omap2_apll_hwops = {

 static void __init of_omap2_apll_setup(struct device_node *node)
 {
-	struct dpll_data *ad = NULL;
-	struct clk_hw_omap *clk_hw = NULL;
-	struct clk_init_data *init = NULL;
+	struct dpll_data *ad;
+	struct clk_hw_omap *clk_hw;
+	struct clk_init_data *init = kzalloc(sizeof(*init), GFP_KERNEL);
 	const char *name;
 	struct clk *clk;
 	const char *parent_name;
 	u32 val;
 	int ret;

-	ad = kzalloc(sizeof(*ad), GFP_KERNEL);
+	if (!init)
+		return;
+
 	clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
-	init = kzalloc(sizeof(*init), GFP_KERNEL);
+	if (!clk_hw)
+		goto free_init;

-	if (!ad || !clk_hw || !init)
-		goto cleanup;
+	ad = kzalloc(sizeof(*ad), GFP_KERNEL);
+	if (!ad)
+		goto free_clk_hw;

 	clk_hw->dpll_data = ad;
 	clk_hw->hw.init = init;
@@ -403,12 +407,13 @@ static void __init of_omap2_apll_setup(struct device_node *node)
 	clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
 	if (!IS_ERR(clk)) {
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
-		kfree(init);
-		return;
+		goto free_init;
 	}
 cleanup:
 	kfree(ad);
+free_clk_hw:
 	kfree(clk_hw);
+free_init:
 	kfree(init);
 }
 CLK_OF_DECLARE(omap2_apll_clock, "ti,omap2-apll-clock",
--
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ