From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932162AbcDYMAe (ORCPT ); Mon, 25 Apr 2016 08:00:34 -0400 Received: from mga02.intel.com ([134.134.136.20]:27465 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754351AbcDYMAc (ORCPT ); Mon, 25 Apr 2016 08:00:32 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,532,1455004800"; d="scan'208";a="965935417" Subject: Re: [PATCH] tools/power turbostat: fix overflow read on array slm_freq_table To: Colin King , Len Brown References: <1461521904-9745-1-git-send-email-colin.king@canonical.com> Cc: Hubert Chrzaniuk , Dasaratharaman Chandramouli , linux-kernel@vger.kernel.org From: "Rafael J. Wysocki" Organization: Intel Technology Poland Sp. z o. o., KRS 101882, ul. Slowackiego 173, 80-298 Gdansk Message-ID: <571E06DC.70301@intel.com> Date: Mon, 25 Apr 2016 14:00:28 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <1461521904-9745-1-git-send-email-colin.king@canonical.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/24/2016 8:18 PM, Colin King wrote: > From: Colin Ian King > > 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 Can you please CC this to linux-pm@vger.kernel.org? It is easier to handle then. > --- > 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]; >