Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp213239ybh; Mon, 20 Jul 2020 14:45:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxksuITyHu1CPyfb4hCH7nAe1EvqGCf3GHq2A1P5AEvSVtxiPORwLH3g2Aj1IOOoENtIVye X-Received: by 2002:aa7:d58c:: with SMTP id r12mr24227559edq.160.1595281546558; Mon, 20 Jul 2020 14:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595281546; cv=none; d=google.com; s=arc-20160816; b=fhm4eSwTilPt7r8EnUzVjq9tcnyVL59to332aERp0sKo+VA7njHAgNjdIRt79GMkN1 iQp7V1fcQVOstMbNX/gsSWp+nD8HXGpboZFvebtdFocUAYcu1sn3UDxL4xn5t4Qpfvk3 NkGxCJQW9Ww7FVcz2B/jRg1Q2Wmp2OkOAU69ovSC1B5NFd0KBQNd5lLjnI9shltLdeU4 HwerVCDzRwlwAHIKcn7dc/nzUH3GeQ8daCUAf/kw/6Hpgjc85XZB2JKcbmuoCF2B2i6p 5popW3+aFO9le+ovMKf/Ov+QU6j04ElznlDDmYnvtKj5WEtht0Hi11CMulV0x3lewDll Fdiw== 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:message-id:date:subject:cc:to:from :dkim-signature; bh=7LYjyz91DOcNM8zxGbHNa2U5KJchEAD6beyMePYFmtw=; b=lwj06eGAZ+OJ1faKxMX398qFWM4KPuej2PiH0Fkg1gGVfIhnOjJfzUafx2NShvPzjX zXzeC055w8yCbMekT0T28BSmtCpclpudMzslvhw9RCukaGz+bCoFesHUhNX1b/SwAC+E gb8yqS+3U+TZOj9fO1UXPTSxK6jBDMt1MOLpH88Qx85vFpuSUj5W6axBBdLINVq0YqYs 50XtQVuVPfxzrzYPP+RsgYwXVfTgjfh+/5SrFKcEwAnIR6i3v7DsQ2kchWPjK8ChzYul DG1HULzqKz4x0kZ06LCpy2X0xzG/hR/is9mQVMl5JhvuQZRsGqT8UFNduFxdGFGDc8sS 2knQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hut9npUC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si11303699edr.440.2020.07.20.14.45.20; Mon, 20 Jul 2020 14:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hut9npUC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728387AbgGTVmE (ORCPT + 99 others); Mon, 20 Jul 2020 17:42:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:58336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgGTVjK (ORCPT ); Mon, 20 Jul 2020 17:39:10 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2189207FC; Mon, 20 Jul 2020 21:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595281149; bh=SAMDObAPKgoZIXKFTKFMdIp+C1FyCwxF1h7AKrbE8qE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hut9npUCWy6Ouqn6XcsLAWNqvMFv3x9unk5lOj0f0T7gWhuhPIKyVwOL3B3l1PL3+ nT8QYB6zJBAf+joQM4XCmfPAIvJ/vDOJlwK5Zpte4KwJXGfYI+jrstHjwq83BcVdGO wBtRH++6Wx1BqsI7DJ4nT65xROQTYjptjKuD4dIE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Cristian Marussi , Sudeep Holla , Guenter Roeck , Sasha Levin , linux-hwmon@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 15/19] hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe() Date: Mon, 20 Jul 2020 17:38:46 -0400 Message-Id: <20200720213851.407715-15-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200720213851.407715-1-sashal@kernel.org> References: <20200720213851.407715-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cristian Marussi [ Upstream commit 3ce17cd2b94907f6d91b81b32848044b84c97606 ] SMATCH detected a potential buffer overflow in the manipulation of hwmon_attributes array inside the scmi_hwmon_probe function: drivers/hwmon/scmi-hwmon.c:226 scmi_hwmon_probe() error: buffer overflow 'hwmon_attributes' 6 <= 9 Fix it by statically declaring the size of the array as the maximum possible as defined by hwmon_max define. Signed-off-by: Cristian Marussi Reviewed-by: Sudeep Holla Link: https://lore.kernel.org/r/20200715121338.GA18761@e119603-lin.cambridge.arm.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/scmi-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index 91976b6ca3000..91bfecdb3f5ba 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -99,7 +99,7 @@ static enum hwmon_sensor_types scmi_types[] = { [ENERGY] = hwmon_energy, }; -static u32 hwmon_attributes[] = { +static u32 hwmon_attributes[hwmon_max] = { [hwmon_chip] = HWMON_C_REGISTER_TZ, [hwmon_temp] = HWMON_T_INPUT | HWMON_T_LABEL, [hwmon_in] = HWMON_I_INPUT | HWMON_I_LABEL, -- 2.25.1