mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 05:34:13 +08:00
soc: qcom: socinfo: Fix off-by-one array index bounds check
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: 734c78e7fe
("soc: qcom: socinfo: add info from PMIC models array")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210118113651.71955-1-colin.king@canonical.com
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
parent
3bc4bf77fa
commit
e6393818c8
@ -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)));
|
||||
|
Loading…
Reference in New Issue
Block a user