diff options
author | Douglas Anderson <dianders@chromium.org> | 2018-08-30 13:34:37 -0400 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2018-08-30 17:59:39 -0400 |
commit | 2bdb2a1cca8669cfe15be62b8f1ed966e374585b (patch) | |
tree | e60a7af7d3ce3c1233e768c866401d6d121899c7 | |
parent | 8b69c6dba2300b616737bbfc28685d86d786b11d (diff) |
clk: qcom: Allocate space for NULL terimation in DFS table
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>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
-rw-r--r-- | drivers/clk/qcom/clk-rcg2.c | 3 |
1 files changed, 2 insertions, 1 deletions
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) | |||
993 | struct freq_tbl *freq_tbl; | 993 | struct freq_tbl *freq_tbl; |
994 | int i; | 994 | int i; |
995 | 995 | ||
996 | freq_tbl = kcalloc(MAX_PERF_LEVEL, sizeof(*freq_tbl), GFP_KERNEL); | 996 | /* Allocate space for 1 extra since table is NULL terminated */ |
997 | freq_tbl = kcalloc(MAX_PERF_LEVEL + 1, sizeof(*freq_tbl), GFP_KERNEL); | ||
997 | if (!freq_tbl) | 998 | if (!freq_tbl) |
998 | return -ENOMEM; | 999 | return -ENOMEM; |
999 | rcg->freq_tbl = freq_tbl; | 1000 | rcg->freq_tbl = freq_tbl; |