Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756251AbcK3G3Z (ORCPT ); Wed, 30 Nov 2016 01:29:25 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33686 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810AbcK3G3P (ORCPT ); Wed, 30 Nov 2016 01:29:15 -0500 Date: Tue, 29 Nov 2016 22:29:11 -0800 From: Eduardo Valentin To: Caesar Wang Cc: rui.zhang@intel.com, heiko@sntech.de, smbarber@chromium.org, briannorris@chromium.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: Re: [PATCH v3 4/5] thermal: rockchip: optimize the conversion table Message-ID: <20161130062911.GB28498@localhost.localdomain> References: <1480331524-18741-1-git-send-email-wxt@rock-chips.com> <1480331524-18741-5-git-send-email-wxt@rock-chips.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1480331524-18741-5-git-send-email-wxt@rock-chips.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 398 Lines: 15 Hey, On Mon, Nov 28, 2016 at 07:12:03PM +0800, Caesar Wang wrote: > + num = abs(table->id[mid].code - table->id[mid + 1].code); > + num *= temp - table->id[mid].temp; > + denom = table->id[mid + 1].temp - table->id[mid].temp; isn't the above 'mid + 1' off-by-one when mid ends being == table.length - 1? You would be accessing table->id[table.length], which is wrong memory access, no?