linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (nzxt-kraken3) Bail out for unsupported device variants
@ 2024-05-12 16:19 Guenter Roeck
  2024-05-12 22:25 ` Jonas Malaco
  0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2024-05-12 16:19 UTC (permalink / raw)
  To: Hardware Monitoring
  Cc: Jean Delvare, Guenter Roeck, Dan Carpenter, Jonas Malaco, Aleksa Savic

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: (nzxt-kraken3) Bail out for unsupported device variants
  2024-05-12 16:19 [PATCH] hwmon: (nzxt-kraken3) Bail out for unsupported device variants Guenter Roeck
@ 2024-05-12 22:25 ` Jonas Malaco
  0 siblings, 0 replies; 2+ messages in thread
From: Jonas Malaco @ 2024-05-12 22:25 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Hardware Monitoring, Jean Delvare, Dan Carpenter, Aleksa Savic

On Sun, May 12, 2024 at 09:19:21AM GMT, Guenter Roeck wrote:
> 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
> 

Acked-by: Jonas Malaco <jonas@protocubo.io>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-12 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-12 16:19 [PATCH] hwmon: (nzxt-kraken3) Bail out for unsupported device variants Guenter Roeck
2024-05-12 22:25 ` Jonas Malaco

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 NNTP newsgroup(s).