diff mbox series

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

Message ID YAf+o85Z9lgkq3Nw@mwanda (mailing list archive)
State Accepted
Commit 5fb33d8960dc7abdabc6fe599a30c2c99b082ef6
Headers show
Series soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model() | expand

Commit Message

Dan Carpenter Jan. 20, 2021, 9:57 a.m. UTC
These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
accessing one element beyond the end of the array.

Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/soc/qcom/socinfo.c | 2 +-
 1 file changed, 1 insertions(+), 1 deletions(-)

Comments

Doug Anderson Jan. 20, 2021, 4:25 p.m. UTC | #1
Hi,

On Wed, Jan 20, 2021 at 1:58 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/soc/qcom/socinfo.c | 2 +-
>  1 file changed, 1 insertions(+), 1 deletions(-)

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Dmitry Baryshkov Jan. 20, 2021, 5:55 p.m. UTC | #2
On Wed, 20 Jan 2021 at 12:58, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Stephen Boyd Jan. 20, 2021, 6:32 p.m. UTC | #3
Quoting Dan Carpenter (2021-01-20 01:57:55)
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
> 
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>
patchwork-bot+linux-arm-msm@kernel.org Jan. 21, 2021, 4:50 a.m. UTC | #4
Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

On Wed, 20 Jan 2021 12:57:55 +0300 you wrote:
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
> 
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/soc/qcom/socinfo.c | 2 +-
>  1 file changed, 1 insertions(+), 1 deletions(-)

Here is the summary with links:
  - soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
    https://git.kernel.org/qcom/c/5fb33d8960dc

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index a985ed064669..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);