Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5703984imu; Wed, 30 Jan 2019 02:05:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN5OWAQIaVlNq+p3gvXOKTRhpOJtKuj4D9HhrIgrOjPRMDLk9mRTuIaCP8RACEKsBz2OR6jF X-Received: by 2002:a62:f51a:: with SMTP id n26mr19770985pfh.245.1548842747345; Wed, 30 Jan 2019 02:05:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548842747; cv=none; d=google.com; s=arc-20160816; b=FHYbL4GkAYz9G+MI2vQ5+GHll8Suc2DZ/PX/+EBbzqX7mjSF5Ujg/fAVm7GaYHEaj6 aVFTMrdEPEjLx5ZPJ2vU1shgj3z+sjjlf8JRSNWblxgroYweKNzmQRzHoh12oh32ML8f vaRZ5gcA+OMME23FwkQE2BdHIE+Z8G8lm8o6BfNonxZhRrKQ3/gT2QQPA0OC9Y3eXMlN UulhumtmgqQ5UvuPnEBc34usxQxZEKlWnvjx2qFtZE1vD857FORL41gl3Uy3JyMITLUt QsU/QW4V4d9zUSOydD1NqfNWjqEylD9SITRdlYexzIn3GwIAf/BrbEhmvy4I5rq+Pu+f Dvrg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=oo1kQyMUGCUjislYa6LlOze0vrMNQ5FaLTM41ZieqG8=; b=nnruf8DOEl/h69GrwcHaTWzy3ByhpS7bUrscOabe7/pczQ54+kkq6JbBiGoYhiAwlx 99mHISORB+a+1zp8kn8qUG2h+f4GM24qTICiICKBMAtEBNOeDg7GS2vGakjCVYgVOHT3 jbbkEkKNy6Ruu28hzutL7ZmDjhg1hfJHHH9RjuP42krtkMOZ/oSHq6JBWaOsW8FiMm0w rUfz1FWvBUPGjBZdmKW/xZGgQnb75IvEqgVa5tBR4cu3k5090NLAKJgXC3WsI0Y0xTTC /vqV2P+h5A24UfdC8+sZcjorfI8pl3Aq5SgbWfF01UJNesQM8BdhX4qJRR4Z8Wsg5CLd qL7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UphX7E/q"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si1035405pgl.350.2019.01.30.02.05.31; Wed, 30 Jan 2019 02:05:47 -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; dkim=pass header.i=@linaro.org header.s=google header.b="UphX7E/q"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728829AbfA3KE7 (ORCPT + 99 others); Wed, 30 Jan 2019 05:04:59 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34997 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726713AbfA3KE6 (ORCPT ); Wed, 30 Jan 2019 05:04:58 -0500 Received: by mail-wm1-f65.google.com with SMTP id t200so21070965wmt.0 for ; Wed, 30 Jan 2019 02:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=oo1kQyMUGCUjislYa6LlOze0vrMNQ5FaLTM41ZieqG8=; b=UphX7E/quzi2ltMApn41JSicUG4t2G10B5oXDGv4/PHrDm+nYV12oO/oa6khUAqite YpGzHx2Ddj+hSrUuhGj4aUwnqwXHUUZnAGHP0ESuZt6W8AMo5FRxejjMTq2Q+I/yFbA/ RAQqYclkyy+3PyjN7lBbU4UoWD8p6Sg2NguHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oo1kQyMUGCUjislYa6LlOze0vrMNQ5FaLTM41ZieqG8=; b=aHDp7vW9IbiduLX31+5OAdSF87DNeGHBzbAjQTvVf1y+d6x4DmEcUlvhe6u2vlhL1Q tun63a+JjaJ6gdkqciQlDih1Wai3lvORbJWyobsF/I60en3hDT2e2RiTDUv5rOy2anUJ /RFv2VE0nvPDYigVNK64eMZDKeIAtC1mOc+59YT7GY700lkfzyL1sjdfEik7AEgiScJO 1tmvzbw8e429ILkWtuJALCbX/RVXbVJIyONE/6nd+cyhWpss/+fDL8xPR8CwC2hUYeea lg+C2JMTz3oqIlvWK7IDtR2ODuRWlcavQdtvLKNji6DQexVTm9uXX0LV3HNoD7UAbMDl 4FOw== X-Gm-Message-State: AJcUukdBCTHsKkfGFuihG8rwnglWgo5NjFdYfMW4E+pvCglJfdvJ6H87 KbrjxHQcfA0ocPOP0SKSK5WQnw== X-Received: by 2002:a1c:968a:: with SMTP id y132mr24391391wmd.107.1548842695839; Wed, 30 Jan 2019 02:04:55 -0800 (PST) Received: from [192.168.0.41] (164.30.95.92.rev.sfr.net. [92.95.30.164]) by smtp.googlemail.com with ESMTPSA id a1sm978712wrw.76.2019.01.30.02.04.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 02:04:55 -0800 (PST) Subject: Re: [PATCH] thermal: mtk: Allocate enough space for mtk_thermal. To: Pi-Hsun Shih Cc: Zhang Rui , 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 References: <20190109055724.184692-1-pihsun@chromium.org> <81115ad5-521e-557b-d229-1effb92068a4@linaro.org> From: Daniel Lezcano Message-ID: <49dbd0af-975e-cafb-d1b9-4e491a6c9383@linaro.org> Date: Wed, 30 Jan 2019 11:04:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog