Skip to contentSkip to conversation

hwmon: nzxt: Fix some error handling path in kraken2_probe()

PATCH Applied Christophe JAILLET 3 participants 3 messages Dec 3, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: nzxt: Fix some error handling path in kraken2_probe()

There is no point in calling hid_hw_stop() if hid_hw_start() has failed. There is no point in calling hid_hw_close() if hid_hw_open() has failed.

Update the error handling path accordingly.

Fixes 82e3430dfa8c ("hwmon: add driver for NZXT Kraken X42/X52/X62/X72")

---
Closes added to please checkpatch, not sure if relevant here.

---
 drivers/hwmon/nzxt-kraken2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/nzxt-kraken2.c +2 -2
index 428c77b5fce5..7caf387eb144 100644
@@ -161,13 +161,13 @@ static int kraken2_probe(struct hid_device *hdev,
 	ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
 	if (ret) {
 		hid_err(hdev, "hid hw start failed with %d\n", ret);
-		goto fail_and_stop;
+		return ret;
 	}
 
 	ret = hid_hw_open(hdev);
 	if (ret) {
 		hid_err(hdev, "hid hw open failed with %d\n", ret);
-		goto fail_and_close;
+		goto fail_and_stop;
 	}
 
 	priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "kraken2",
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 38 lines · Christophe JAILLET

There is no point in calling hid_hw_stop() if hid_hw_start() has failed. There is no point in calling hid_hw_close() if hid_hw_open() has failed.

Update the error handling path accordingly.

Fixes 82e3430dfa8c ("hwmon: add driver for NZXT Kraken X42/X52/X62/X72")

---
Closes added to please checkpatch, not sure if relevant here.

---
 drivers/hwmon/nzxt-kraken2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/nzxt-kraken2.c +2 -2
index 428c77b5fce5..7caf387eb144 100644
@@ -161,13 +161,13 @@ static int kraken2_probe(struct hid_device *hdev,
 	ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
 	if (ret) {
 		hid_err(hdev, "hid hw start failed with %d\n", ret);
-		goto fail_and_stop;
+		return ret;
 	}
 
 	ret = hid_hw_open(hdev);
 	if (ret) {
 		hid_err(hdev, "hid hw open failed with %d\n", ret);
-		goto fail_and_close;
+		goto fail_and_stop;
 	}
 
 	priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "kraken2",
Signature · 1 line
2.34.1

That was a silly mistake from me. Thanks for finding and fixing it.

maintainer Applied
#2 lore raw
In reply to Christophe JAILLET
Quoted 10 lines · Christophe JAILLET

There is no point in calling hid_hw_stop() if hid_hw_start() has failed. There is no point in calling hid_hw_close() if hid_hw_open() has failed.

Update the error handling path accordingly.

Fixes 82e3430dfa8c ("hwmon: add driver for NZXT Kraken X42/X52/X62/X72")

Applied.

Quoted 2 lines

---
Closes added to please checkpatch, not sure if relevant here.

One of the few checkpatch warnings which may be ignored for hwmon patches. Sometimes there _is_ no report of a problem or, like in this case, it is reported in some unrelated exchange. I don't drop it if provided, but I don't require it either.

Guenter