All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>,
	"kernelci.org bot" <bot@kernelci.org>,
	"Sudip Mukherjee (Codethink)" <sudipm.mukherjee@gmail.com>
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	[thread overview]
Message-ID: <20220923152009.1721739-1-nathan@kernel.org> (raw)

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" <bot@kernelci.org>
Reported-by: "Sudip Mukherjee (Codethink)" <sudipm.mukherjee@gmail.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 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


             reply	other threads:[~2022-09-23 15:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23 15:20 Nathan Chancellor [this message]
2022-09-27  9:36 ` [PATCH -next] thermal/intel/int340x: Initialized ret in error path in int340x_thermal_zone_add() Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220923152009.1721739-1-nathan@kernel.org \
    --to=nathan@kernel.org \
    --cc=amitk@kernel.org \
    --cc=bot@kernelci.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=ndesaulniers@google.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.