Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp391010imu; Tue, 8 Jan 2019 22:46:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN51QJPz2r8m6y197kPcihc5iPSLF40OrAkSyM+ZBfCNYgau9xy/nBpBZVrlmVIcKrxAMulT X-Received: by 2002:a62:798f:: with SMTP id u137mr4836338pfc.168.1547016365411; Tue, 08 Jan 2019 22:46:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547016365; cv=none; d=google.com; s=arc-20160816; b=YEHvsHi/W5ZA5Eh70ChxlijiEgXMvEaoPNK9bSkZVY3JFh80MzY4pW/B1qGHhxSe+1 eaYgBmCmQltPRkXyDm1EadIyy1yISlQECJ4PsYMr6h7EqnZg5Dyr6Y/yeE9xc1b0qb0X IlW105FHphw0JiA5Y1WrxJdTynOyVNHP9blNTN88jSo1jd6O+Ine5Wvd0ETBIFx58Qgt z36WSt9QOvNs1dVr0ifCqqi32FVAEOlScaZM3s7RzcuJEf8LKpAlgpYp0YCSnXb1JNrl f0Y2/6P3n9ZGr2/oc1k16wJsuaVzJ6umNxZ9FNg14TFTqOIoRoXI2dvvC6eAdHP8k3HS jEHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=Aa1uCBP59MSaio3VSgOuyxVekJ64BN6jptSWeh729UM=; b=vu6AWhkTA+uQJR8SgQZ8r/xZnvL/pYjCcpE/KGm5kKTC51B1GNcGVjrqTHMOIvgZSP 9rqx27yiiT5qHVT34tJlg7IpY3IGtnA0t0P4DvD4SLdqWZrg1ll+M7ZGx9eggW6fctAp 3Ey2cjkhE4UrNJzdF8DkEIEvHSiZ8ENs6MddvRXXxtcPrHc3F953+VzfXnuqLvJX82yz Z9x98vD3BeA+4UPcfub2rWXTgsNJQzlGTQkRS/eRZBUdcWzAbaSXsaWDuGOVNGueDmsS aYxi0HFLkiwXv1oVGZRJcVezIUp0kLHp52PwS0MQZaU2QF7XfQUl4JqtpVgoidfGKCNG qahw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=JRMrjNqv; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i96si10209466plb.188.2019.01.08.22.45.49; Tue, 08 Jan 2019 22:46:05 -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=fail header.i=@chromium.org header.s=google header.b=JRMrjNqv; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729414AbfAIF5r (ORCPT + 99 others); Wed, 9 Jan 2019 00:57:47 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34927 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbfAIF5q (ORCPT ); Wed, 9 Jan 2019 00:57:46 -0500 Received: by mail-pg1-f195.google.com with SMTP id s198so2837490pgs.2 for ; Tue, 08 Jan 2019 21:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Aa1uCBP59MSaio3VSgOuyxVekJ64BN6jptSWeh729UM=; b=JRMrjNqvaANp2nwjIVi+v62CRRtIdsNdmrS4Xik+9U7Ze3Q3sZ79s8pImwHbYTgQjS Dv+rbhL7lHgHqTtv6NNNHHhY87BF4q3oM9eBrLFz9thIB3V/f8TqwV0lhqohwKlxYWDB p07mbFI5okRzpWqPFYdIgURZ1V/O/oYdbhPO8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Aa1uCBP59MSaio3VSgOuyxVekJ64BN6jptSWeh729UM=; b=INRmbTV8ze30bNIHgzI6lBZyiuX2WAo9msUxDJv47co3RuETsGRjZyIJD+Q9KCs41b VeLXoQ8bZV+9JU6rwPPYLx+5ABFjyRCWern5l/UYvcx/IhM9+XfrfK3rcwVala/c7cMD oFtHomSKZm0bRF6U4EDDMWQf3xuq59w8Srqp+8twDeQYeiWH12Q5wj0ASarawo87OCCW 7UvL325+1a30eeUy+VCmZM8413ZYuzrj/K56/J8vdNOLc4q8dKIlCNo7NLhJmXEOBVB1 skLCnSWz//+SW3u6BRgj/+u8WZIxcA+QrIGUzTUzNc/8ucEAP+acgjSyzyCt1wCUW7bu O+yw== X-Gm-Message-State: AJcUukdd+YkGxCski5Br9OnuUZJXQWk8A7dDQaaEpXfBm6tuL7OdpbHn 7PWxlVm5GHUL4NI87HeQBq0QEg== X-Received: by 2002:a63:a91a:: with SMTP id u26mr4147921pge.349.1547013465557; Tue, 08 Jan 2019 21:57:45 -0800 (PST) Received: from pihsun-z840.tpe.corp.google.com ([2401:fa00:1:10:7889:7a43:f899:134c]) by smtp.googlemail.com with ESMTPSA id i1sm102627966pgb.46.2019.01.08.21.57.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jan 2019 21:57:44 -0800 (PST) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Matthias Brugger , linux-pm@vger.kernel.org (open list:THERMAL), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] thermal: mtk: Allocate enough space for mtk_thermal. Date: Wed, 9 Jan 2019 13:57:24 +0800 Message-Id: <20190109055724.184692-1-pihsun@chromium.org> X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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