linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] clk: meson: fix protection against undefined clks
@ 2017-07-27 16:17 Jerome Brunet
  2017-07-27 16:17 ` [PATCH 1/2] clk: meson: meson8b: " Jerome Brunet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jerome Brunet @ 2017-07-27 16:17 UTC (permalink / raw)
  To: Neil Armstrong, Michael Turquette, Stephen Boyd, Kevin Hilman
  Cc: Jerome Brunet, Carlo Caione, linux-amlogic, linux-clk,
	linux-arm-kernel, linux-kernel

If the last clkids defined have no hw pointer associated with them in
the hw_onecell_data array, the initialization is going to crash badly
because the array is not big enough.

The patchset makes sure the array is big enough, and that each clkid is
associated with a valid hw pointer, or NULL.

Doing it in two patches to ease backport, since we are not fixing the
same commit on meson8b and gxbb

Jerome Brunet (2):
  clk: meson: meson8b: fix protection against undefined clks
  clk: meson: gxbb: fix protection against undefined clks

 drivers/clk/meson/gxbb.c    | 2 ++
 drivers/clk/meson/meson8b.c | 1 +
 2 files changed, 3 insertions(+)

-- 
2.9.4

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

* [PATCH 1/2] clk: meson: meson8b: fix protection against undefined clks
  2017-07-27 16:17 [PATCH 0/2] clk: meson: fix protection against undefined clks Jerome Brunet
@ 2017-07-27 16:17 ` Jerome Brunet
  2017-07-27 16:17 ` [PATCH 2/2] clk: meson: gxbb: " Jerome Brunet
  2017-07-28 10:07 ` [PATCH 0/2] clk: meson: " Neil Armstrong
  2 siblings, 0 replies; 4+ messages in thread
From: Jerome Brunet @ 2017-07-27 16:17 UTC (permalink / raw)
  To: Neil Armstrong, Michael Turquette, Stephen Boyd, Kevin Hilman
  Cc: Jerome Brunet, Carlo Caione, linux-amlogic, linux-clk,
	linux-arm-kernel, linux-kernel

meson8b clock driver gracefully handles case where the clkid is defined
but the clock hw pointer is not provided, as long as it is not at the end
of the hw_onecell_data array.

This patch ensure that the last entries are defined as well to handle
this particular case.

Fixes: e92f7cca446e ("clk: meson8b: clean up fixed rate clocks")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/clk/meson/meson8b.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
index bb3f1de876b1..7629aa09472a 100644
--- a/drivers/clk/meson/meson8b.c
+++ b/drivers/clk/meson/meson8b.c
@@ -585,6 +585,7 @@ static struct clk_hw_onecell_data meson8b_hw_onecell_data = {
 		[CLKID_MPLL0]		    = &meson8b_mpll0.hw,
 		[CLKID_MPLL1]		    = &meson8b_mpll1.hw,
 		[CLKID_MPLL2]		    = &meson8b_mpll2.hw,
+		[CLK_NR_CLKS]		    = NULL,
 	},
 	.num = CLK_NR_CLKS,
 };
-- 
2.9.4

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

* [PATCH 2/2] clk: meson: gxbb: fix protection against undefined clks
  2017-07-27 16:17 [PATCH 0/2] clk: meson: fix protection against undefined clks Jerome Brunet
  2017-07-27 16:17 ` [PATCH 1/2] clk: meson: meson8b: " Jerome Brunet
@ 2017-07-27 16:17 ` Jerome Brunet
  2017-07-28 10:07 ` [PATCH 0/2] clk: meson: " Neil Armstrong
  2 siblings, 0 replies; 4+ messages in thread
From: Jerome Brunet @ 2017-07-27 16:17 UTC (permalink / raw)
  To: Neil Armstrong, Michael Turquette, Stephen Boyd, Kevin Hilman
  Cc: Jerome Brunet, Carlo Caione, linux-amlogic, linux-clk,
	linux-arm-kernel, linux-kernel

gxbb clock driver gracefully handles case where the clkid is defined but
the clock hw pointer is not provided, as long as it is not at the end of
the hw_onecell_data array.

This patch ensure that the last entries are defined as well to handle
this particular case.

Fixes: a70c6e06ed7c ("clk: meson: gxbb: protect against holes in the onecell_data array")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/clk/meson/gxbb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index a897ea45327c..8409d86cda24 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -1183,6 +1183,7 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = {
 		[CLKID_32K_CLK]		    = &gxbb_32k_clk.hw,
 		[CLKID_32K_CLK_SEL]	    = &gxbb_32k_clk_sel.hw,
 		[CLKID_32K_CLK_DIV]	    = &gxbb_32k_clk_div.hw,
+		[NR_CLKS]		    = NULL,
 	},
 	.num = NR_CLKS,
 };
@@ -1305,6 +1306,7 @@ static struct clk_hw_onecell_data gxl_hw_onecell_data = {
 		[CLKID_32K_CLK]		    = &gxbb_32k_clk.hw,
 		[CLKID_32K_CLK_SEL]	    = &gxbb_32k_clk_sel.hw,
 		[CLKID_32K_CLK_DIV]	    = &gxbb_32k_clk_div.hw,
+		[NR_CLKS]		    = NULL,
 	},
 	.num = NR_CLKS,
 };
-- 
2.9.4

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

* Re: [PATCH 0/2] clk: meson: fix protection against undefined clks
  2017-07-27 16:17 [PATCH 0/2] clk: meson: fix protection against undefined clks Jerome Brunet
  2017-07-27 16:17 ` [PATCH 1/2] clk: meson: meson8b: " Jerome Brunet
  2017-07-27 16:17 ` [PATCH 2/2] clk: meson: gxbb: " Jerome Brunet
@ 2017-07-28 10:07 ` Neil Armstrong
  2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2017-07-28 10:07 UTC (permalink / raw)
  To: Jerome Brunet, Michael Turquette, Stephen Boyd, Kevin Hilman
  Cc: Carlo Caione, linux-amlogic, linux-clk, linux-arm-kernel, linux-kernel

On 07/27/2017 06:17 PM, Jerome Brunet wrote:
> If the last clkids defined have no hw pointer associated with them in
> the hw_onecell_data array, the initialization is going to crash badly
> because the array is not big enough.
> 
> The patchset makes sure the array is big enough, and that each clkid is
> associated with a valid hw pointer, or NULL.
> 
> Doing it in two patches to ease backport, since we are not fixing the
> same commit on meson8b and gxbb
> 
> Jerome Brunet (2):
>   clk: meson: meson8b: fix protection against undefined clks
>   clk: meson: gxbb: fix protection against undefined clks
> 
>  drivers/clk/meson/gxbb.c    | 2 ++
>  drivers/clk/meson/meson8b.c | 1 +
>  2 files changed, 3 insertions(+)
> 

Applied to clk-meson's fixes/drivers !

Thanks,
Neil

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

end of thread, other threads:[~2017-07-28 10:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-27 16:17 [PATCH 0/2] clk: meson: fix protection against undefined clks Jerome Brunet
2017-07-27 16:17 ` [PATCH 1/2] clk: meson: meson8b: " Jerome Brunet
2017-07-27 16:17 ` [PATCH 2/2] clk: meson: gxbb: " Jerome Brunet
2017-07-28 10:07 ` [PATCH 0/2] clk: meson: " Neil Armstrong

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