All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check
@ 2021-01-18 11:36 Colin King
  2021-01-20  9:57   ` Dan Carpenter
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Colin King @ 2021-01-18 11:36 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Dmitry Baryshkov, linux-arm-msm
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

There is an off-by-one array index bounds check on array
pmic_models. Fix this by checking using < rather than <= on
the array size.

Addresses-Coverity: ("Out-of-bounds read")
Fixes: 734c78e7febf ("soc: qcom: socinfo: add info from PMIC models array")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/soc/qcom/socinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index a985ed064669..f449df560d93 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -332,7 +332,7 @@ static int qcom_show_pmic_model_array(struct seq_file *seq, void *p)
 		unsigned int model = SOCINFO_MINOR(get_unaligned_le32(ptr + 2 * i * sizeof(u32)));
 		unsigned int die_rev = get_unaligned_le32(ptr + (2 * i + 1) * sizeof(u32));
 
-		if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model])
+		if (model < ARRAY_SIZE(pmic_models) && pmic_models[model])
 			seq_printf(seq, "%s %u.%u\n", pmic_models[model],
 				   SOCINFO_MAJOR(le32_to_cpu(die_rev)),
 				   SOCINFO_MINOR(le32_to_cpu(die_rev)));
-- 
2.29.2


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

end of thread, other threads:[~2021-01-21  4:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 11:36 [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check Colin King
2021-01-20  9:57 ` [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model() Dan Carpenter
2021-01-20  9:57   ` Dan Carpenter
2021-01-20 16:25   ` Doug Anderson
2021-01-20 16:25     ` Doug Anderson
2021-01-20 17:55   ` Dmitry Baryshkov
2021-01-20 17:55     ` Dmitry Baryshkov
2021-01-20 18:32   ` Stephen Boyd
2021-01-20 18:32     ` Stephen Boyd
2021-01-21  4:50   ` patchwork-bot+linux-arm-msm
2021-01-20  9:58 ` [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check Dan Carpenter
2021-01-20  9:58   ` Dan Carpenter
2021-01-21  4:50 ` patchwork-bot+linux-arm-msm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.