From patchwork Fri Feb 16 16:32:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13560300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CF9FC48BEF for ; Fri, 16 Feb 2024 16:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Asmm7xlsEaTuEZOnnCzgk3u7nOjI0WkmUONmFfjaxH4=; b=2d5gcqqmtMdV9K oKI/Cyv6+DE273n7ayxPvq6n/5j8luJEp9DFFS5AAJOkml+o73QYDzlq70raA2LfiTsuZkPfID1zM OcQEShP2Rrpf6P9CkTvURVf1T/TggCcJCSWBE8kDCv0vi1+KHytvvM66V0JP7MN/RXr3SH8nkn/N/ d95FL7ivkLefMqxj0jYFBVl3bZ/1ONZ/qWLs4HyV3Uc5A+6xftB/4/OhwqsUwfEcg4WdCulyHj66w nbKX9qxyxhV4u8oMklL9G+qKjLW7wjrAlUbseeg3DEuiilfI48cbelDLvbaDdt+gxaOwgZCwjLZrm dvL7fE6r090Q0V486M+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb19A-000000030aO-3yfF; Fri, 16 Feb 2024 16:33:08 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb198-000000030a0-48WU for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2024 16:33:08 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 02211CE2A09; Fri, 16 Feb 2024 16:33:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 063E8C433F1; Fri, 16 Feb 2024 16:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708101184; bh=Of7v1GxhPAmcslNCv2upPf4LImqPPOW1O8gZ/gUB0K0=; h=From:To:Cc:Subject:Date:From; b=CCt+eSywPtfHMHf159xCuj+SEArQm0vinZXB6BlnoVBqEYpD8oB39RXX/hgLEHvQ6 8Rb/uYvmOTcCclLOSkiWIKKM2Ej3gutNnqUMK2l5YHCw35HAQgkHAKWFFuE2988sS6 WpbEean1hiftDBiGRvTDLCVq20o5L5C9ajE8+ttVRzE2keG2Dkns3Nyi1Z0xqd8uT3 4Jocxw6KCYxdzZ+Uae58DbpQLhsBwjISLfai3uErE8cN/lq2vU9feE/vhoPzmLNtHK /TkwduhA77vJ4pv8CsOe4UYULsp04ut6lWK5lJj0f5ZLaOe6g6pKhmOOLI4aEcmtTM wpdK7UrXHZOMg== From: Arnd Bergmann To: Sudeep Holla , Cristian Marussi Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] firmware: arm_scmi: avoid returning uninialized data Date: Fri, 16 Feb 2024 17:32:53 +0100 Message-Id: <20240216163259.1927967-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240216_083307_262754_AD47E684 X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Clang notices that there is a code path through scmi_powercap_notify_supported() that returns an undefined value: drivers/firmware/arm_scmi/powercap.c:821:11: error: variable 'supported' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] 821 | else if (evt_id == SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/firmware/arm_scmi/powercap.c:824:9: note: uninitialized use occurs here 824 | return supported; | ^~~~~~~~~ drivers/firmware/arm_scmi/powercap.c:821:7: note: remove the 'if' if its condition is always true 821 | else if (evt_id == SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 822 | supported = dom_info->notify_powercap_measurement_change; drivers/firmware/arm_scmi/powercap.c:811:16: note: initialize the variable 'supported' to silence this warning 811 | bool supported; | ^ Return 'false' here, which is probably what was intended. Fixes: c92a75fe84ce ("firmware: arm_scmi: Implement Powercap .is_notify_supported callback") Signed-off-by: Arnd Bergmann --- drivers/firmware/arm_scmi/powercap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/firmware/arm_scmi/powercap.c b/drivers/firmware/arm_scmi/powercap.c index aae91f47303e..8ee3be8776b0 100644 --- a/drivers/firmware/arm_scmi/powercap.c +++ b/drivers/firmware/arm_scmi/powercap.c @@ -820,6 +820,8 @@ scmi_powercap_notify_supported(const struct scmi_protocol_handle *ph, supported = dom_info->notify_powercap_cap_change; else if (evt_id == SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED) supported = dom_info->notify_powercap_measurement_change; + else + supported = false; return supported; }