From: Daniil Dulov <d.dulov@aladdin.ru>
To: Zhang Rui <rui.zhang@intel.com>
Cc: Daniil Dulov <d.dulov@aladdin.ru>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Amit Kucheria <amitk@kernel.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Chen Yu <yu.c.chen@intel.com>, Sasha Levin <sashal@kernel.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<lvc-project@linuxtesting.org>
Subject: [PATCH] thermal: intel_powerclamp: Check for a possible array out of bounds access.
Date: Fri, 2 Jun 2023 01:55:46 -0700 [thread overview]
Message-ID: <20230602085546.376086-1-d.dulov@aladdin.ru> (raw)
ratio may be equal to MAX_TARGET_RATIO - 1 that will result in
out of bound access.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d6d71ee4a14a ("PM: Introduce Intel PowerClamp Driver")
Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
---
drivers/thermal/intel/intel_powerclamp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index fb04470d7d4b..9deaf2b8ccf6 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -277,7 +277,8 @@ static unsigned int get_compensation(int ratio)
comp = (cal_data[ratio].steady_comp +
cal_data[ratio - 1].steady_comp +
cal_data[ratio - 2].steady_comp) / 3;
- } else if (cal_data[ratio].confidence >= CONFIDENCE_OK &&
+ } else if (ratio < MAX_TARGET_RATIO - 1 &&
+ cal_data[ratio].confidence >= CONFIDENCE_OK &&
cal_data[ratio - 1].confidence >= CONFIDENCE_OK &&
cal_data[ratio + 1].confidence >= CONFIDENCE_OK) {
comp = (cal_data[ratio].steady_comp +
--
2.25.1
next reply other threads:[~2023-06-02 9:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 8:55 Daniil Dulov [this message]
2023-06-04 16:13 ` Rafael J. Wysocki
2023-06-05 16:36 ` srinivas pandruvada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230602085546.376086-1-d.dulov@aladdin.ru \
--to=d.dulov@aladdin.ru \
--cc=amitk@kernel.org \
--cc=arjan@linux.intel.com \
--cc=daniel.lezcano@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rui.zhang@intel.com \
--cc=sashal@kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=yu.c.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®