linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
@ 2019-11-09 15:19 Tian Yunhao
  2019-11-11 12:39 ` Maxime Ripard
  0 siblings, 1 reply; 6+ messages in thread
From: Tian Yunhao @ 2019-11-09 15:19 UTC (permalink / raw)
  Cc: tian yunhao, Stephen Boyd, Michael Turquette, linux-kernel,
	Maxime Ripard, Chen-Yu Tsai, linux-clk, linux-arm-kernel,
	Icenowy Zheng

The hws field of sun8i_v3s_hw_clks has only 74
members. However, the number specified by CLK_NUMBER
is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
fault that is not always reproducible.

This patch adds a protective field [CLK_NUMBER] which ensures
ARRAY_SIZE(.hws) is always greater than .num, thus eliminates
this error.

Signed-off-by: Yunhao Tian <t123yh@outlook.com>
---
 drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
index 5c779eec454b..de7fce7f32e6 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
@@ -617,6 +617,7 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = {
 		[CLK_AVS]		= &avs_clk.common.hw,
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
+		[CLK_NUMBER]    = NULL,
 	},
 	.num	= CLK_NUMBER,
 };
@@ -699,6 +700,7 @@ static struct clk_hw_onecell_data sun8i_v3_hw_clks = {
 		[CLK_AVS]		= &avs_clk.common.hw,
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
+		[CLK_NUMBER]    = NULL,
 	},
 	.num	= CLK_NUMBER,
 };
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
@ 2019-11-25 12:58 Yunhao Tian
  2019-11-28 17:44 ` Maxime Ripard
  0 siblings, 1 reply; 6+ messages in thread
From: Yunhao Tian @ 2019-11-25 12:58 UTC (permalink / raw)
  Cc: Stephen Boyd, Michael Turquette, linux-kernel, Maxime Ripard,
	Chen-Yu Tsai, Yunhao Tian, linux-clk, linux-arm-kernel,
	Icenowy Zheng

The hws field of sun8i_v3s_hw_clks has only 74
members. However, the number specified by CLK_NUMBER
is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
fault that is not always reproducible.

This patch fixes the problem by specifying correct clock number.

Signed-off-by: Yunhao Tian <18373444@buaa.edu.cn>
---
 drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
index 5c779eec454b..0e36ca3bf3d5 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
@@ -618,7 +618,7 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = {
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
 	},
-	.num	= CLK_NUMBER,
+	.num	= CLK_PLL_DDR1 + 1,
 };
 
 static struct clk_hw_onecell_data sun8i_v3_hw_clks = {
@@ -700,7 +700,7 @@ static struct clk_hw_onecell_data sun8i_v3_hw_clks = {
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
 	},
-	.num	= CLK_NUMBER,
+	.num	= CLK_I2S0 + 1,
 };
 
 static struct ccu_reset_map sun8i_v3s_ccu_resets[] = {
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-11-28 17:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09 15:19 [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks Tian Yunhao
2019-11-11 12:39 ` Maxime Ripard
2019-11-12 12:59   ` Icenowy Zheng
2019-11-12 19:16     ` Maxime Ripard
2019-11-25 12:58 Yunhao Tian
2019-11-28 17:44 ` Maxime Ripard

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).