diff mbox series

tools/power/x86/intel-speed-select: Fix off by one check

Message ID YtVdXen0K8KH0kwu@kili (mailing list archive)
State Superseded, archived
Headers show
Series tools/power/x86/intel-speed-select: Fix off by one check | expand

Commit Message

Dan Carpenter July 18, 2022, 1:17 p.m. UTC
Change > MAX_DIE_PER_PACKAGE to >= MAX_DIE_PER_PACKAGE to prevent
accessing one element beyond the end of the array.

Fixes: 7fd786dfbd2c ("tools/power/x86/intel-speed-select: OOB daemon mode")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 tools/power/x86/intel-speed-select/isst-daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Srinivas Pandruvada July 18, 2022, 3:29 p.m. UTC | #1
On Mon, 2022-07-18 at 16:17 +0300, Dan Carpenter wrote:
> Change > MAX_DIE_PER_PACKAGE to >= MAX_DIE_PER_PACKAGE to prevent
> accessing one element beyond the end of the array.
> 
> Fixes: 7fd786dfbd2c ("tools/power/x86/intel-speed-select: OOB daemon
> mode")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks. I will add to PULL request.


> ---
>  tools/power/x86/intel-speed-select/isst-daemon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c
> b/tools/power/x86/intel-speed-select/isst-daemon.c
> index dd372924bc82..d0400c6684ba 100644
> --- a/tools/power/x86/intel-speed-select/isst-daemon.c
> +++ b/tools/power/x86/intel-speed-select/isst-daemon.c
> @@ -41,7 +41,7 @@ void process_level_change(int cpu)
>         time_t tm;
>         int ret;
>  
> -       if (pkg_id >= MAX_PACKAGE_COUNT || die_id >
> MAX_DIE_PER_PACKAGE) {
> +       if (pkg_id >= MAX_PACKAGE_COUNT || die_id >=
> MAX_DIE_PER_PACKAGE) {
>                 debug_printf("Invalid package/die info for cpu:%d\n",
> cpu);
>                 return;
>         }
diff mbox series

Patch

diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c b/tools/power/x86/intel-speed-select/isst-daemon.c
index dd372924bc82..d0400c6684ba 100644
--- a/tools/power/x86/intel-speed-select/isst-daemon.c
+++ b/tools/power/x86/intel-speed-select/isst-daemon.c
@@ -41,7 +41,7 @@  void process_level_change(int cpu)
 	time_t tm;
 	int ret;
 
-	if (pkg_id >= MAX_PACKAGE_COUNT || die_id > MAX_DIE_PER_PACKAGE) {
+	if (pkg_id >= MAX_PACKAGE_COUNT || die_id >= MAX_DIE_PER_PACKAGE) {
 		debug_printf("Invalid package/die info for cpu:%d\n", cpu);
 		return;
 	}