Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4881319pjb; Mon, 27 Jul 2020 07:30:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgzMaxDYe3K4P4/n+tRJ93/PhVaI3MvsAmVFgw9U/G8ds3UNCmSLjSrQSB3toWUwiyEcy9 X-Received: by 2002:a05:6402:1494:: with SMTP id e20mr21279817edv.2.1595860205334; Mon, 27 Jul 2020 07:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860205; cv=none; d=google.com; s=arc-20160816; b=PmHIKVVwxtMArmiIByyCMXqtE2xq1ZPR5HBr3Cf3e6iN6LRI8kj3hkb+6U/rCUJvwf 4dgb+7wciVZUCw9+GvLbZ+4zbnc45iNdLsTvp3rCJgZH+by9RoGnC2UEq1WPGuqibieS 7VnHL4RhwCsayFc3xIwU8k4zJBIXSYpm04hr+CKjHAGLgvdicXYje1jV9I/xVTf7TXVB 2Fn9CCYnxE/JatkTXesoJv8lwgN8jfMv7icss5GkFm/jW0ADvOB1+PvhIzHGI/RrdkIB /lOb00Y+UxXWcUumnbSjP1xEUrV7/msDtaWKbvHBOTZL4WSLCFwk7Mrxh1+5nwVM4q2G pnMA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1Cwi/+RI5sqEeIMyDwa0e7Dsl0Lfz4fVnLUK1L3QtsI=; b=jgbzXSXMxViW3EKljXMbRIv8mO7b+eH89mZyXyZxMlx/vuVP9hU03PX/A0f/p3XpeL /bfczuB+Ivk6wFyauIB1A42h3ZGtsDEOwLVCo7Cb9whKpFElw5ecAi9FdfNYmxavonET KXxcn5ldypQAS8xPRSc9eH3c15ijVJWYeXPd9y9g+c9pertrHxIIFGCF4qFp+YlH8jXg HjuP2NY1rZpIeM6zmKBIoX1/EiNlqGPzWsf/xs0QAkVrZfTjiaLhan8Wxyptt4s8YHoR Bk8nbbsyzJJFTEswjjnt5K6bOpseyRAxBdiHhPBM+3LabHrseVQbA6AotrK/PqXlcGqg jERQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r4rc4CRO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x8si6928129edl.120.2020.07.27.07.29.43; Mon, 27 Jul 2020 07:30:05 -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=r4rc4CRO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732235AbgG0OYQ (ORCPT + 99 others); Mon, 27 Jul 2020 10:24:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:53578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732202AbgG0OYK (ORCPT ); Mon, 27 Jul 2020 10:24:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C17B2083E; Mon, 27 Jul 2020 14:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859850; bh=bsvqLDOLlUmaBR5IRdHrcZS4+AMxNdAhjU/AXGsiBvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4rc4CROeX8MUP2Xb5V6EnydkE+dFqCYPhGbtjyeDZlH1Nld4od6+IJDwCnoqzCFw jm8oTcZ5fwi5UlSng6zV7xhonZKpz8HBzk+FjMw8/qR3TAcqgIVpmZBmO0rV2Ylde4 5BIqDsBtwPQPBk3jYeNMpaocKEnXwKlRg0T8GCiw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cristian Marussi , Sudeep Holla , Guenter Roeck , Sasha Levin Subject: [PATCH 5.7 130/179] hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe() Date: Mon, 27 Jul 2020 16:05:05 +0200 Message-Id: <20200727134938.986229976@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 286d3cfda7de8..d421e691318b3 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -147,7 +147,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