cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [cocci] [PATCH 0/2] clk: imx: composite-8m: Adjustments for __imx8m_clk_hw_composite()
@ 2023-12-22 16:33 Markus Elfring
  2023-12-22 16:35 ` [cocci] [PATCH 1/2] clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection Markus Elfring
  2023-12-22 16:37 ` [cocci] [PATCH 2/2] clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite() Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Elfring @ 2023-12-22 16:33 UTC (permalink / raw)
  To: Abel Vesa, Fabio Estevam, Michael Turquette, Peng Fan,
	Sascha Hauer, Shawn Guo, Stephen Boyd, kernel, linux-imx,
	linux-clk, linux-arm-kernel, kernel-janitors
  Cc: LKML, cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 22 Dec 2023 17:24:32 +0100

A few update suggestions were taken into account
from source code analysis.

Markus Elfring (2):
  Less function calls after error detection
  Delete two unnecessary initialisations

 drivers/clk/imx/clk-composite-8m.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

--
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [cocci] [PATCH 1/2] clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection
  2023-12-22 16:33 [cocci] [PATCH 0/2] clk: imx: composite-8m: Adjustments for __imx8m_clk_hw_composite() Markus Elfring
@ 2023-12-22 16:35 ` Markus Elfring
  2023-12-22 16:37 ` [cocci] [PATCH 2/2] clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite() Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2023-12-22 16:35 UTC (permalink / raw)
  To: Abel Vesa, Fabio Estevam, Michael Turquette, Peng Fan,
	Sascha Hauer, Shawn Guo, Stephen Boyd, kernel, linux-imx,
	linux-clk, linux-arm-kernel, kernel-janitors
  Cc: LKML, cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 22 Dec 2023 16:48:24 +0100

The function “kfree” was called in up to three cases
by the function “__imx8m_clk_hw_composite” during error handling
even if the passed variables contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/imx/clk-composite-8m.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
index 27a08c50ac1d..eb5392f7a257 100644
--- a/drivers/clk/imx/clk-composite-8m.c
+++ b/drivers/clk/imx/clk-composite-8m.c
@@ -220,7 +220,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,

 	mux = kzalloc(sizeof(*mux), GFP_KERNEL);
 	if (!mux)
-		goto fail;
+		return ERR_CAST(hw);

 	mux_hw = &mux->hw;
 	mux->reg = reg;
@@ -230,7 +230,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,

 	div = kzalloc(sizeof(*div), GFP_KERNEL);
 	if (!div)
-		goto fail;
+		goto free_mux;

 	div_hw = &div->hw;
 	div->reg = reg;
@@ -260,7 +260,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
 	if (!mcore_booted) {
 		gate = kzalloc(sizeof(*gate), GFP_KERNEL);
 		if (!gate)
-			goto fail;
+			goto free_div;

 		gate_hw = &gate->hw;
 		gate->reg = reg;
@@ -272,13 +272,15 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
 			mux_hw, mux_ops, div_hw,
 			divider_ops, gate_hw, &clk_gate_ops, flags);
 	if (IS_ERR(hw))
-		goto fail;
+		goto free_gate;

 	return hw;

-fail:
+free_gate:
 	kfree(gate);
+free_div:
 	kfree(div);
+free_mux:
 	kfree(mux);
 	return ERR_CAST(hw);
 }
--
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [cocci] [PATCH 2/2] clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite()
  2023-12-22 16:33 [cocci] [PATCH 0/2] clk: imx: composite-8m: Adjustments for __imx8m_clk_hw_composite() Markus Elfring
  2023-12-22 16:35 ` [cocci] [PATCH 1/2] clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection Markus Elfring
@ 2023-12-22 16:37 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2023-12-22 16:37 UTC (permalink / raw)
  To: Abel Vesa, Fabio Estevam, Michael Turquette, Peng Fan,
	Sascha Hauer, Shawn Guo, Stephen Boyd, kernel, linux-imx,
	linux-clk, linux-arm-kernel, kernel-janitors
  Cc: LKML, cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 22 Dec 2023 17:11:03 +0100

Two local variables will eventually be set to appropriate pointers
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/imx/clk-composite-8m.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
index eb5392f7a257..8cc07d056a83 100644
--- a/drivers/clk/imx/clk-composite-8m.c
+++ b/drivers/clk/imx/clk-composite-8m.c
@@ -212,9 +212,9 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
 {
 	struct clk_hw *hw = ERR_PTR(-ENOMEM), *mux_hw;
 	struct clk_hw *div_hw, *gate_hw = NULL;
-	struct clk_divider *div = NULL;
+	struct clk_divider *div;
 	struct clk_gate *gate = NULL;
-	struct clk_mux *mux = NULL;
+	struct clk_mux *mux;
 	const struct clk_ops *divider_ops;
 	const struct clk_ops *mux_ops;

--
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-22 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-22 16:33 [cocci] [PATCH 0/2] clk: imx: composite-8m: Adjustments for __imx8m_clk_hw_composite() Markus Elfring
2023-12-22 16:35 ` [cocci] [PATCH 1/2] clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection Markus Elfring
2023-12-22 16:37 ` [cocci] [PATCH 2/2] clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite() Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).