mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Len Brown <len.brown@intel.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Hubert Chrzaniuk <hubert.chrzaniuk@intel.com>,
	Dasaratharaman Chandramouli 
	<dasaratharaman.chandramouli@intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] tools/power turbostat: fix overflow read on array slm_freq_table
Date: Sun, 24 Apr 2016 19:18:24 +0100	[thread overview]
Message-ID: <1461521904-9745-1-git-send-email-colin.king@canonical.com> (raw)

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

When i >= SLM_BCLK_FREQS, the frequency read from the slm_freq_table
is off the end of the array because msr is set to 3 rather than the
actual array index i.  Set i to 3 rather than msr to fix this.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 tools/power/x86/turbostat/turbostat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index acbf7ff..a66f07c 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -3050,7 +3050,7 @@ double slm_bclk(void)
 	i = msr & 0xf;
 	if (i >= SLM_BCLK_FREQS) {
 		fprintf(outf, "SLM BCLK[%d] invalid\n", i);
-		msr = 3;
+		i = 3;
 	}
 	freq = slm_freq_table[i];
 
-- 
2.7.4

             reply	other threads:[~2016-04-24 18:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 18:18 Colin King [this message]
2016-04-25 12:00 ` Rafael J. Wysocki

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=1461521904-9745-1-git-send-email-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=dasaratharaman.chandramouli@intel.com \
    --cc=hubert.chrzaniuk@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@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®