From: Dan Carpenter Date: Wed, 20 Jan 2021 09:57:55 +0000 (+0300) Subject: soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model() X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5fb33d8960dc7abdabc6fe599a30c2c99b082ef6;p=uclinux-h8%2Flinux.git 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: Dmitry Baryshkov Reviewed-by: Douglas Anderson Reviewed-by: Stephen Boyd Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/YAf+o85Z9lgkq3Nw@mwanda Signed-off-by: Bjorn Andersson --- diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index f449df560d93..5b4ad24a022b 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -309,7 +309,7 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p) if (model < 0) 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]); else seq_printf(seq, "unknown (%d)\n", model);