Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH] hwmon: nzxt: Fix some error handling path in kraken2_probe()
@ 2023-12-03 15:24 Christophe JAILLET
  2023-12-03 16:37 ` Jonas Malaco
  2023-12-03 17:11 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2023-12-03 15:24 UTC (permalink / raw)
  To: Jonas Malaco, Jean Delvare, Guenter Roeck
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, Aleksa Savic,
	linux-hwmon

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")
Reported-by: Aleksa Savic <savicaleksa83@gmail.com>
Closes: https://lore.kernel.org/all/121470f0-6c1f-418a-844c-7ec2e8a54b8e@gmail.com/
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Closes added to please checkpatch, not sure if relevant here.
---
 drivers/hwmon/nzxt-kraken2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/nzxt-kraken2.c b/drivers/hwmon/nzxt-kraken2.c
index 428c77b5fce5..7caf387eb144 100644
--- a/drivers/hwmon/nzxt-kraken2.c
+++ b/drivers/hwmon/nzxt-kraken2.c
@@ -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",
-- 
2.34.1


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

* Re: [PATCH] hwmon: nzxt: Fix some error handling path in kraken2_probe()
  2023-12-03 15:24 [PATCH] hwmon: nzxt: Fix some error handling path in kraken2_probe() Christophe JAILLET
@ 2023-12-03 16:37 ` Jonas Malaco
  2023-12-03 17:11 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Jonas Malaco @ 2023-12-03 16:37 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Jean Delvare, Guenter Roeck, linux-kernel, kernel-janitors,
	Aleksa Savic, linux-hwmon

On Sun, Dec 03, 2023 at 04:24:05PM +0100, Christophe JAILLET wrote:
> 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")
> Reported-by: Aleksa Savic <savicaleksa83@gmail.com>
> Closes: https://lore.kernel.org/all/121470f0-6c1f-418a-844c-7ec2e8a54b8e@gmail.com/
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Closes added to please checkpatch, not sure if relevant here.
> ---
>  drivers/hwmon/nzxt-kraken2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/nzxt-kraken2.c b/drivers/hwmon/nzxt-kraken2.c
> index 428c77b5fce5..7caf387eb144 100644
> --- a/drivers/hwmon/nzxt-kraken2.c
> +++ b/drivers/hwmon/nzxt-kraken2.c
> @@ -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",
> -- 
> 2.34.1
> 

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

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

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

* Re: [PATCH] hwmon: nzxt: Fix some error handling path in kraken2_probe()
  2023-12-03 15:24 [PATCH] hwmon: nzxt: Fix some error handling path in kraken2_probe() Christophe JAILLET
  2023-12-03 16:37 ` Jonas Malaco
@ 2023-12-03 17:11 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2023-12-03 17:11 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Jonas Malaco, Jean Delvare, linux-kernel, kernel-janitors,
	Aleksa Savic, linux-hwmon

On Sun, Dec 03, 2023 at 04:24:05PM +0100, Christophe JAILLET wrote:
> 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")
> Reported-by: Aleksa Savic <savicaleksa83@gmail.com>
> Closes: https://lore.kernel.org/all/121470f0-6c1f-418a-844c-7ec2e8a54b8e@gmail.com/
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Reviewed-by: Jonas Malaco <jonas@protocubo.io>

Applied.

> ---
> 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

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

end of thread, other threads:[~2023-12-03 17:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03 15:24 [PATCH] hwmon: nzxt: Fix some error handling path in kraken2_probe() Christophe JAILLET
2023-12-03 16:37 ` Jonas Malaco
2023-12-03 17:11 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox