Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5904132imu; Wed, 30 Jan 2019 05:39:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN6HTIKe40prNOXDUYjwEtK2+y5eODZJaFMHhxX3nOzdKqOhpsH2aiYCAKE97BKaPk+fWiC2 X-Received: by 2002:a62:31c1:: with SMTP id x184mr31404114pfx.204.1548855547606; Wed, 30 Jan 2019 05:39:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548855547; cv=none; d=google.com; s=arc-20160816; b=rm4/O/o8l08G73sdCw5OxIj8dWbDz32Py40Dj9XIfmLJvHWIjjk65gcA0SpdfA2Y1Z uUCZV5D5V/3LsmrKlPI6NSrKb6zL6GZvjtrqtNLWp7w2QnGMSq0zdVhEGQX+MaPlMlN9 D5Ms4tPj+/78KZAISJoayaW3ib8frUpLi5od480gtZA7XCFRT7nianTOGbvdroohhFIC mx/SyC8PpyFkivRk+qOaUlqg/vl25HJKY1uPAoWwazD4rmd+B3ulochpPcI6Eml13kDB GyR4eLLUhPOEhB+I9lc4uebtaaojg4i0LcLEJm/ganQJvz84UOC170NfCHE2k1cntlkR W2sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=fKajgqzgm0J9K0id4LOe5cJhUh9R5qYUPMUkbrCBCxU=; b=wn15LBy4wrbfwRj0gg1qGe78bcn0TTndJhvvzBofSqLI4b03t+SJ69QdvYqq3wWswb BUZxF7DmhVvlAWHWr7cMW1FYmXApaS1C2xFmtu4Z2ovSl+J6khdxc7MyY7q+YUj4TBwV rysdvae3O1aceoeOPRH2ZoA+kzRVSni+7YYUJN/cj9IWKDYVZlXVDo5iMKhI/Mjas+2B 15l9ygMpc6JWfvqgX3d7XxL7APSHkENmyW2uzSO//j4l003RNfu5HABlkX3cNb2lzUN0 O2Ru3Sh3U1CnZpGvDldk/kY6XxUNSksDqdUp/LzO3OmmBipGH2idl2lxVx79GcNiWs+U Xtrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d189si1358776pgc.393.2019.01.30.05.38.52; Wed, 30 Jan 2019 05:39:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731068AbfA3Niq (ORCPT + 99 others); Wed, 30 Jan 2019 08:38:46 -0500 Received: from mga18.intel.com ([134.134.136.126]:34163 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbfA3Nip (ORCPT ); Wed, 30 Jan 2019 08:38:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2019 05:38:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,540,1539673200"; d="scan'208";a="139178088" Received: from wchen25-mobl9.ccr.corp.intel.com ([10.249.173.109]) by fmsmga002.fm.intel.com with ESMTP; 30 Jan 2019 05:38:42 -0800 Message-ID: <1548855520.2161.3.camel@intel.com> Subject: Re: [PATCH] thermal: mtk: Allocate enough space for mtk_thermal. From: Zhang Rui To: Daniel Lezcano , Pi-Hsun Shih Cc: Eduardo Valentin , Matthias Brugger , "open list:THERMAL" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , open list , Michael.Kao@mediatek.com Date: Wed, 30 Jan 2019 21:38:40 +0800 In-Reply-To: <49dbd0af-975e-cafb-d1b9-4e491a6c9383@linaro.org> References: <20190109055724.184692-1-pihsun@chromium.org> <81115ad5-521e-557b-d229-1effb92068a4@linaro.org> <49dbd0af-975e-cafb-d1b9-4e491a6c9383@linaro.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On δΈ‰, 2019-01-30 at 11:04 +0100, Daniel Lezcano wrote: > On 30/01/2019 10:25, Pi-Hsun Shih wrote: > > > > On Wed, Jan 30, 2019 at 3:44 PM Daniel Lezcano > > wrote: > > > > > > > > > On 30/01/2019 07:04, Peter Shih wrote: > > > > > > > > Adding Michael Kao to cc list. > > > > > > > > On Wed, Jan 9, 2019 at 1:57 PM Pi-Hsun Shih > > > g> wrote: > > > > > > > > > > > > > > > The mtk_thermal struct contains a 'struct mtk_thermal_bank > > > > > banks[];', > > > > > but the allocation only allocates sizeof(struct mtk_thermal) > > > > > bytes, > > > > > which cause out of bound access with the ->banks[] member. > > > > > Change it to > > > > > a fixed size array instead. > > > Even if the fix is correct, it pushes back the bug later in time > > > if a > > > new board containing more than MAX_NUM_ZONES is introduced. I > > > suggest to > > > dynamically allocate the array with the 'num_banks' value. > > > > > For the current code structure, those mtk_thermal_data are > > statically declared, > > so if there's new board containing more than MAX_NUM_ZONES of > > bank_data, it > > would actually be a compile error. > > > > I'm fine with either way, but feel like that this is simpler than > > manually > > calculating the size needed for allocation. > Right, I missed it can be caught at compile time. > > Reviewed-by: Daniel Lezcano > As this is a bugfix, I will take it and queue it for next -rc. thanks, rui > >