From patchwork Tue Jul 25 09:48:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Seo X-Patchwork-Id: 13326241 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75023C41513 for ; Tue, 25 Jul 2023 09:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232128AbjGYJsw (ORCPT ); Tue, 25 Jul 2023 05:48:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbjGYJsp (ORCPT ); Tue, 25 Jul 2023 05:48:45 -0400 Received: from rs227.mailgun.us (rs227.mailgun.us [209.61.151.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6291E1AA for ; Tue, 25 Jul 2023 02:48:42 -0700 (PDT) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=equiv.tech; q=dns/txt; s=mx; t=1690278521; x=1690285721; h=Content-Transfer-Encoding: MIME-Version: Message-Id: Date: Subject: Subject: Cc: To: To: From: From: Sender: Sender; bh=a7euifVUehZsKlaZIpC9d5sGc1HeYiQSbpWf0EJ7QP8=; b=aMwyHjc1Ie3XzN3jSnYF0T6fY+zfs44bBdIaPzPeija+U4Ejh8SuJD9bgUd4Orwl45uUqrhiwTCXAerA/Kqe3rKEc6Z8XghNoEPbAPc3SBPf8T6kSAoTIDcZDShYvrQ0bV8MUCw2Xo/xxhioZSuaEtrcYBKGwBPrWtxX8ylAyAPqyy0G9L9eV7u/+LLNn4FvezaY7Y30ze/rGeRu3YBzTgfCGHDY/OMEtzEyPo2WyaXaefBAHMHDyI8cAeU+oNe7LhSFKDAIYixlHkbqszOsFhrgqAAaopRed09nfdW5MdFUGHx97yWTASh8A4WyITgsuOqr7PsbZx+VToUlYipfIA== X-Mailgun-Sending-Ip: 209.61.151.227 X-Mailgun-Sid: WyJkOWUwNSIsImxpbnV4LWh3bW9uQHZnZXIua2VybmVsLm9yZyIsIjkzZDVhYiJd Received: from mail.equiv.tech (equiv.tech [142.93.28.83]) by 292765024a19 with SMTP id 64bf9a7995a6293efb65da64 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 25 Jul 2023 09:48:41 GMT Sender: james@equiv.tech From: James Seo To: Jean Delvare , Guenter Roeck Cc: James Seo , Dan Carpenter , linux-hwmon@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: (hp-wmi-sensors) Initialize pevents in hp_wmi_sensors_init() Date: Tue, 25 Jul 2023 02:48:17 -0700 Message-Id: <20230725094817.588640-1-james@equiv.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The following warning is given by the Smatch static checker: drivers/hwmon/hp-wmi-sensors.c:1937 hp_wmi_sensors_init() error: uninitialized symbol 'pevents'. If there are no instances of the HPBIOS_PlatformEvents WMI object available, init_platform_events() never initializes this pointer, which may then be passed to hp_wmi_debugfs_init() uninitialized. The impact should be limited because hp_wmi_debugfs_init() uses this pointer only if the count of HPBIOS_PlatformEvents instances is _not_ zero, while conversely, it will be uninitialized only if the count of such instances _is_ zero. However, passing it uninitialized still constitutes a bug. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/linux-hwmon/f72c129b-8c57-406a-bf41-bd889b65ea0f@moroto.mountain/ Signed-off-by: James Seo --- drivers/hwmon/hp-wmi-sensors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 55612007f16b5d7b1fb83a7b0f5bb686829db7c7 diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c index 3a99cc5f44b2..17ae62f88bbf 100644 --- a/drivers/hwmon/hp-wmi-sensors.c +++ b/drivers/hwmon/hp-wmi-sensors.c @@ -1913,7 +1913,7 @@ static bool add_event_handler(struct hp_wmi_sensors *state) static int hp_wmi_sensors_init(struct hp_wmi_sensors *state) { struct hp_wmi_info *connected[HP_WMI_MAX_INSTANCES]; - struct hp_wmi_platform_events *pevents; + struct hp_wmi_platform_events *pevents = NULL; struct device *dev = &state->wdev->dev; struct hp_wmi_info *info; struct device *hwdev;