public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (corsair-psu) Close HID device on probe errors
@ 2026-04-24 13:50 Myeonghun Pak
  2026-04-24 15:37 ` Wilken Gottwalt
  0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-04-24 13:50 UTC (permalink / raw)
  To: Wilken Gottwalt, Guenter Roeck
  Cc: linux-hwmon, linux-kernel, stable, Myeonghun Pak

corsairpsu_probe() opens the HID device before sending the device init
and firmware-info commands. If either command fails, the error path jumps
directly to fail_and_stop and skips hid_hw_close().

Use the existing fail_and_close label for those post-open failures so the
open count and low-level close callback are balanced before hid_hw_stop().

Fixes: d115b51e0e56 ("hwmon: add Corsair PSU HID controller driver")
Cc: stable@vger.kernel.org
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/hwmon/corsair-psu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c
index dddbd2463f..76f3e1da68 100644
--- a/drivers/hwmon/corsair-psu.c
+++ b/drivers/hwmon/corsair-psu.c
@@ -796,13 +796,13 @@ static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id
 	ret = corsairpsu_init(priv);
 	if (ret < 0) {
 		dev_err(&hdev->dev, "unable to initialize device (%d)\n", ret);
-		goto fail_and_stop;
+		goto fail_and_close;
 	}
 
 	ret = corsairpsu_fwinfo(priv);
 	if (ret < 0) {
 		dev_err(&hdev->dev, "unable to query firmware (%d)\n", ret);
-		goto fail_and_stop;
+		goto fail_and_close;
 	}
 
 	corsairpsu_get_criticals(priv);
-- 
2.50.1


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

* Re: [PATCH] hwmon: (corsair-psu) Close HID device on probe errors
  2026-04-24 13:50 [PATCH] hwmon: (corsair-psu) Close HID device on probe errors Myeonghun Pak
@ 2026-04-24 15:37 ` Wilken Gottwalt
  0 siblings, 0 replies; 2+ messages in thread
From: Wilken Gottwalt @ 2026-04-24 15:37 UTC (permalink / raw)
  To: Myeonghun Pak; +Cc: Guenter Roeck, linux-hwmon, linux-kernel, stable

On Fri, 24 Apr 2026 22:50:51 +0900
Myeonghun Pak <mhun512@gmail.com> wrote:

> corsairpsu_probe() opens the HID device before sending the device init
> and firmware-info commands. If either command fails, the error path jumps
> directly to fail_and_stop and skips hid_hw_close().
> 
> Use the existing fail_and_close label for those post-open failures so the
> open count and low-level close callback are balanced before hid_hw_stop().
> 
> Fixes: d115b51e0e56 ("hwmon: add Corsair PSU HID controller driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  drivers/hwmon/corsair-psu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c
> index dddbd2463f..76f3e1da68 100644
> --- a/drivers/hwmon/corsair-psu.c
> +++ b/drivers/hwmon/corsair-psu.c
> @@ -796,13 +796,13 @@ static int corsairpsu_probe(struct hid_device *hdev, const struct
> hid_device_id ret = corsairpsu_init(priv);
>  	if (ret < 0) {
>  		dev_err(&hdev->dev, "unable to initialize device (%d)\n", ret);
> -		goto fail_and_stop;
> +		goto fail_and_close;
>  	}
>  
>  	ret = corsairpsu_fwinfo(priv);
>  	if (ret < 0) {
>  		dev_err(&hdev->dev, "unable to query firmware (%d)\n", ret);
> -		goto fail_and_stop;
> +		goto fail_and_close;
>  	}
>  
>  	corsairpsu_get_criticals(priv);

I really had to go back to the initial commit to check, if I introduced that
issue later. But nope, I had it that way from the start. Good catch, I totally
missed that. Thank you.

greetings,
Wilken

Reviewed-by: Wilken Gottwalt <wilken.gottwalt@posteo.net>

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

end of thread, other threads:[~2026-04-24 15:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 13:50 [PATCH] hwmon: (corsair-psu) Close HID device on probe errors Myeonghun Pak
2026-04-24 15:37 ` Wilken Gottwalt

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