* [PATCH] clk: qcom: Allocate space for NULL terimation in DFS table
@ 2018-08-30 17:34 Douglas Anderson
2018-08-30 21:59 ` Stephen Boyd
0 siblings, 1 reply; 2+ messages in thread
From: Douglas Anderson @ 2018-08-30 17:34 UTC (permalink / raw)
To: Stephen Boyd, Taniya Das
Cc: Douglas Anderson, Michael Turquette, linux-arm-msm, linux-kernel,
Andy Gross, David Brown, linux-soc, linux-clk
The table allocated in clk_rcg2_dfs_populate_freq_table() is
eventually iterated over by qcom_find_freq() which assumes that the
table is NULL terminated. Allocate one extra space in the array for
the NULL termination. Initting of the NULL termination is implicit
due to kcalloc().
Fixes: cc4f6944d0e3 ("clk: qcom: Add support for RCG to register for DFS")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
drivers/clk/qcom/clk-rcg2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
index d5d77f9ad170..6e3bd195d012 100644
--- a/drivers/clk/qcom/clk-rcg2.c
+++ b/drivers/clk/qcom/clk-rcg2.c
@@ -993,7 +993,8 @@ static int clk_rcg2_dfs_populate_freq_table(struct clk_rcg2 *rcg)
struct freq_tbl *freq_tbl;
int i;
- freq_tbl = kcalloc(MAX_PERF_LEVEL, sizeof(*freq_tbl), GFP_KERNEL);
+ /* Allocate space for 1 extra since table is NULL terminated */
+ freq_tbl = kcalloc(MAX_PERF_LEVEL + 1, sizeof(*freq_tbl), GFP_KERNEL);
if (!freq_tbl)
return -ENOMEM;
rcg->freq_tbl = freq_tbl;
--
2.19.0.rc0.228.g281dcd1b4d0-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: qcom: Allocate space for NULL terimation in DFS table
2018-08-30 17:34 [PATCH] clk: qcom: Allocate space for NULL terimation in DFS table Douglas Anderson
@ 2018-08-30 21:59 ` Stephen Boyd
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2018-08-30 21:59 UTC (permalink / raw)
To: Douglas Anderson, Taniya Das
Cc: Douglas Anderson, Michael Turquette, linux-arm-msm, linux-kernel,
Andy Gross, David Brown, linux-soc, linux-clk
Quoting Douglas Anderson (2018-08-30 10:34:37)
> The table allocated in clk_rcg2_dfs_populate_freq_table() is
> eventually iterated over by qcom_find_freq() which assumes that the
> table is NULL terminated. Allocate one extra space in the array for
> the NULL termination. Initting of the NULL termination is implicit
> due to kcalloc().
> =
> Fixes: cc4f6944d0e3 ("clk: qcom: Add support for RCG to register for DFS")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-30 21:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-30 17:34 [PATCH] clk: qcom: Allocate space for NULL terimation in DFS table Douglas Anderson
2018-08-30 21:59 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox