Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5517830imu; Tue, 29 Jan 2019 22:05:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN5nAHj96ohgOqTbTivFoF/KiZ6lbyOFcwn3RnlxXmcCn0jotMQyfq9b+rDm5theCuR4oJ81 X-Received: by 2002:a62:33c1:: with SMTP id z184mr29028603pfz.104.1548828315354; Tue, 29 Jan 2019 22:05:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548828315; cv=none; d=google.com; s=arc-20160816; b=fm9UkgWl2kz+whbV4R9SoVbVRcVmCAYKh/0jagN8yrgmnJKEaZ/SvlPvtzzAbB5lkH K5x3GxNOXNOCsauZ9d4QUNY4/KD+aP/gXHJTd/Q+pxizfzo6EB151/SaLDIhp5gRGdXq 1cW2i+QreAWxKHYzM4TALSaBd0G4tUDBZJotQ863wAzmupOhlbLjjzLGGmeE2rol/4iZ Fvk4p1Baxhfz88jq5uYspA7Cr20RQFQWFbBblrSCkGXAx920j5EkfsOuet8XxgiC8xEJ /UY1I9w7B+H6vr2mwjg1w1bcQkTNLNMMS8+VnVs2hyU9NZRHwErAWiehUeKyt16RqxyN VBLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:cc:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aJTjGP6xuRvN5ml+k+nOAP5sZjlzx1oTAMIdkprynv0=; b=eJ/7H8IhmCP2WXIpHDQCV+GmjhI1e1+eDsRlj/MYv5J8mi5+3I1cucmG6O8RhHroWK X5NXHmeIlDpCWMWD8gb6TvFzYzkZCV8jnasyv+9N0uH8RmwM9eBjRJnndluCse2hj0ay WbIXdm1RxJ9AYuLdO+FAI4UCUgZicTPHGc6hV2lb70ZqDjCsla5qXsn9vWwU388w0ULe VjAu5sdQJIKItDQo0q3UeSa+Q7dAaXrkOe2eFtsxSPakcps3UGXCQq287E2ntKxFJqNm pVGghGv2o4zHidxpNnKwcmBZk9KybnV3l+a62VSUslHTGylhnBmkoKTfpKQdllBfV2Lb iNOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lpWYcu2O; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v184si558152pgd.295.2019.01.29.22.04.59; Tue, 29 Jan 2019 22:05:15 -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=@chromium.org header.s=google header.b=lpWYcu2O; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726452AbfA3GEy (ORCPT + 99 others); Wed, 30 Jan 2019 01:04:54 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:40760 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbfA3GEy (ORCPT ); Wed, 30 Jan 2019 01:04:54 -0500 Received: by mail-ed1-f65.google.com with SMTP id g22so18008178edr.7 for ; Tue, 29 Jan 2019 22:04:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=aJTjGP6xuRvN5ml+k+nOAP5sZjlzx1oTAMIdkprynv0=; b=lpWYcu2O8idu2AvZOES6EGCS7R4zW9JSKzrx9qM1j8xVnuOT6vBc2iqeD9SmfZnl5y yU5/U3BhAzV37UBcpsLgX6MWgQJBp/JNKOZqSV/iOsXFa4SHy2uerRdb7Sx3yP4PiCsv wL/i9LVhnh0CTokQkNmy4WGalv1r2zg7K+txY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:cc; bh=aJTjGP6xuRvN5ml+k+nOAP5sZjlzx1oTAMIdkprynv0=; b=VtegwtzFHeGB01LcjzcRXwjJ7J9lxvwTYHuEJBmTPLEb96pospz5J3VfHwDHrO7m3E uGNkslRS1G5biDAot6qyEYCTofSfqWnoleoh63rnjigpUHAirJcxVxQzfFM4T/W887Mj 0i9MLReFp9zk5qz7fUwVGdzL9mwbaEDOw+NKk/33oORBT3/+2x5koOlpx+MJ2h24Ndyl QvdCIDvrn0xa2LTM9Jv8kejretrgqXkWdhhdWOA/UgbT6HxxeLDjXBJ6tNMfCqGIIKaM y1E1XaT4ase0VZanzfpOSQR2qUNEF4srbNK+Wb4uvN26oftJKPBrQIcSujvjsyVphf8x J+nw== X-Gm-Message-State: AJcUukfeUgtXcPHY38twRqbeT8kZO0uBJZuLq4XzfAfjhRD8bR4JgrN6 cjr4YHfSnnGdg2BjHerJiuBkvyeqZIT7mItty+7jCg== X-Received: by 2002:a50:f5af:: with SMTP id u44mt25022648edm.172.1548828292400; Tue, 29 Jan 2019 22:04:52 -0800 (PST) MIME-Version: 1.0 References: <20190109055724.184692-1-pihsun@chromium.org> In-Reply-To: <20190109055724.184692-1-pihsun@chromium.org> From: Peter Shih Date: Wed, 30 Jan 2019 14:04:40 +0800 Message-ID: Subject: Re: [PATCH] thermal: mtk: Allocate enough space for mtk_thermal. Cc: Zhang Rui , Eduardo Valentin , Daniel Lezcano , Matthias Brugger , "open list:THERMAL" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , open list , Michael.Kao@mediatek.com Content-Type: text/plain; charset="UTF-8" To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > Signed-off-by: Pi-Hsun Shih > --- > drivers/thermal/mtk_thermal.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c > index 0691f260f6eabe..ea11edb3fcced6 100644 > --- a/drivers/thermal/mtk_thermal.c > +++ b/drivers/thermal/mtk_thermal.c > @@ -159,6 +159,9 @@ > #define MT7622_NUM_SENSORS_PER_ZONE 1 > #define MT7622_TS1 0 > > +/* The maximum number of banks */ > +#define MAX_NUM_ZONES 8 > + > struct mtk_thermal; > > struct thermal_bank_cfg { > @@ -178,7 +181,7 @@ struct mtk_thermal_data { > const int *sensor_mux_values; > const int *msr; > const int *adcpnp; > - struct thermal_bank_cfg bank_data[]; > + struct thermal_bank_cfg bank_data[MAX_NUM_ZONES]; > }; > > struct mtk_thermal { > @@ -197,7 +200,7 @@ struct mtk_thermal { > s32 vts[MT8173_NUM_SENSORS]; > > const struct mtk_thermal_data *conf; > - struct mtk_thermal_bank banks[]; > + struct mtk_thermal_bank banks[MAX_NUM_ZONES]; > }; > > /* MT8173 thermal sensor data */ > -- > 2.20.1.97.g81188d93c3-goog >