Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFF173D90 for ; Fri, 23 Sep 2022 15:20:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6B72C43142; Fri, 23 Sep 2022 15:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663946426; bh=zo7rFZiPS4WyTBZk4VHnI8cDdMwygNZyE43ol0e2o2A=; h=From:To:Cc:Subject:Date:From; b=h5A9XThDA/5s0nOAX9forsdLayrzgXUza7l79K6258CeVyLTGUt6X96ZBEPlttNp5 ElY629wCutz4/DSMBngmRLN37ymIDXCrKV/Z2J6jov2aGTDZS4bkyZbVrUsPgnnbig yqDUPOVPVI82nAtprBZMueiVWOHOBWkCOsQi3r/9/PBuhqMgwsKjbhOa0KFz5Ia5ga FesASNFIjqev89LM8TbV6f0uz9NdHPJ6XfW7MlY5FZbM7WXYQZK/8HegplFfsL3tOO 9djqqHdCD9lVmJpKW6oZAbuByK69CJ3xUbSxMjXmvykRA9FiAOhnIFGmLKDGuYyXRw uNUmczkVos0qg== From: Nathan Chancellor To: "Rafael J. Wysocki" , Daniel Lezcano Cc: Amit Kucheria , Zhang Rui , Srinivas Pandruvada , Nick Desaulniers , Tom Rix , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor , "kernelci.org bot" , "Sudip Mukherjee (Codethink)" Subject: [PATCH -next] thermal/intel/int340x: Initialized ret in error path in int340x_thermal_zone_add() Date: Fri, 23 Sep 2022 08:20:09 -0700 Message-Id: <20220923152009.1721739-1-nathan@kernel.org> X-Mailer: git-send-email 2.37.3 Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Clang warns: drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:222:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (!int34x_thermal_zone->ops) ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:279:17: note: uninitialized use occurs here return ERR_PTR(ret); ^~~ drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:222:2: note: remove the 'if' if its condition is always false if (!int34x_thermal_zone->ops) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:211:9: note: initialize the variable 'ret' to silence this warning int ret; ^ = 0 1 error generated. If kmemdup() fails, -ENOMEM should be returned. Fixes: f6f6f9a01374 ("thermal/intel/int340x: Replace parameter to simplify") Link: https://github.com/ClangBuiltLinux/linux/issues/1717 Reported-by: "kernelci.org bot" Reported-by: "Sudip Mukherjee (Codethink)" Signed-off-by: Nathan Chancellor --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index ea05be8c2834..228f44260b27 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -219,8 +219,10 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, int34x_thermal_zone->ops = kmemdup(&int340x_thermal_zone_ops, sizeof(int340x_thermal_zone_ops), GFP_KERNEL); - if (!int34x_thermal_zone->ops) + if (!int34x_thermal_zone->ops) { + ret = -ENOMEM; goto err_ops_alloc; + } if (get_temp) int34x_thermal_zone->ops->get_temp = get_temp; base-commit: 2b109cffe6836f0bb464639cdcc59fc537e3ba41 -- 2.37.3