Skip to contentSkip to conversation

hwmon: (nzxt-kraken3) Bail out for unsupported device variants

PATCH In review Guenter Roeck 2 participants 2 messages May 12, 2024

Subsystems (2)
lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (nzxt-kraken3) Bail out for unsupported device variants

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.

Cc Jonas Malaco <[email protected]>
Cc Aleksa Savic <[email protected]>
Fixes cbeb479ff4cd ("hwmon: (nzxt-kraken3) Decouple device names from kinds")

---
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(-)
drivers/hwmon/nzxt-kraken3.c +2 -1
index 0b3f04c740b0..00f3ac90a290 100644
@@ -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);
Signature · 1 line
2.39.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 43 lines · Guenter Roeck

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.

Cc Jonas Malaco <[email protected]>
Cc Aleksa Savic <[email protected]>
Fixes cbeb479ff4cd ("hwmon: (nzxt-kraken3) Decouple device names from kinds")

---
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(-)
drivers/hwmon/nzxt-kraken3.c +2 -1
index 0b3f04c740b0..00f3ac90a290 100644
@@ -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);
Signature · 1 line
2.39.2