Commit 5fb33d89 authored by Dan Carpenter's avatar Dan Carpenter Committed by Bjorn Andersson

soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()

These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
accessing one element beyond the end of the array.
Acked-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
Fixes: e9247e2c ("soc: qcom: socinfo: fix printing of pmic_model")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YAf+o85Z9lgkq3Nw@mwandaSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent e6393818
...@@ -309,7 +309,7 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p) ...@@ -309,7 +309,7 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p)
if (model < 0) if (model < 0)
return -EINVAL; return -EINVAL;
if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model]) if (model < ARRAY_SIZE(pmic_models) && pmic_models[model])
seq_printf(seq, "%s\n", pmic_models[model]); seq_printf(seq, "%s\n", pmic_models[model]);
else else
seq_printf(seq, "unknown (%d)\n", model); seq_printf(seq, "unknown (%d)\n", model);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment