Linux-Hwmon Archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Jonas Malaco <jonas@protocubo.io>,
	Aleksa Savic <savicaleksa83@gmail.com>
Subject: [PATCH] hwmon: (nzxt-kraken3) Bail out for unsupported device variants
Date: Sun, 12 May 2024 09:19:21 -0700	[thread overview]
Message-ID: <20240512161921.850683-1-linux@roeck-us.net> (raw)

Dan Carpenter reports:

Commit cbeb479ff4cd ("hwmon: (nzxt-kraken3) Decouple device names
from kinds") from Apr 28, 2024 (linux-next), leads to the following
Smatch static checker warning:

	drivers/hwmon/nzxt-kraken3.c:957 kraken3_probe()
	error: uninitialized symbol 'device_name'.

Indeed, 'device_name' will be uninitizalized if an unknown product is
encountered. In practice this should not matter because the driver
should not instantiate on unknown products, but lets play safe and
bail out if that happens.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-hwmon/b1738c50-db42-40f0-a899-9c027c131ffb@moroto.mountain/
Cc: Jonas Malaco <jonas@protocubo.io>
Cc: Aleksa Savic <savicaleksa83@gmail.com>
Fixes: cbeb479ff4cd ("hwmon: (nzxt-kraken3) Decouple device names from kinds")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
I updated the SHA in Dan's report; the branch has since been rebased.

 drivers/hwmon/nzxt-kraken3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/nzxt-kraken3.c b/drivers/hwmon/nzxt-kraken3.c
index 0b3f04c740b0..00f3ac90a290 100644
--- a/drivers/hwmon/nzxt-kraken3.c
+++ b/drivers/hwmon/nzxt-kraken3.c
@@ -928,7 +928,8 @@ static int kraken3_probe(struct hid_device *hdev, const struct hid_device_id *id
 		device_name = "kraken2023elite";
 		break;
 	default:
-		break;
+		ret = -ENODEV;
+		goto fail_and_close;
 	}
 
 	priv->buffer = devm_kzalloc(&hdev->dev, MAX_REPORT_LENGTH, GFP_KERNEL);
-- 
2.39.2


             reply	other threads:[~2024-05-12 16:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-12 16:19 Guenter Roeck [this message]
2024-05-12 22:25 ` [PATCH] hwmon: (nzxt-kraken3) Bail out for unsupported device variants Jonas Malaco

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=20240512161921.850683-1-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=dan.carpenter@linaro.org \
    --cc=jdelvare@suse.com \
    --cc=jonas@protocubo.io \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=savicaleksa83@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).