All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qingshuang Fu" <fffsqian@163.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (nzxt-smart2) Check return value of init_device() in probe
Date: Tue, 04 Aug 2026 08:00:01 +0000	[thread overview]
Message-ID: <20260804080002.570A61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804074842.505923-1-fffsqian@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Sysfs read and write handlers wait indefinitely for hardware reports without providing a mechanism to break the wait on device disconnect, causing the device unbind thread to deadlock.
--

--- Patch [1]: [PATCH] hwmon: (nzxt-smart2) Check return value of init_device() in probe ---
commit 18435050bb0408be0aa1e570c7a2976a468d52c0
Author: Qingshuang Fu <fuqingshuang@kylinos.cn>

hwmon: (nzxt-smart2) Check return value of init_device() in probe

This commit updates the nzxt-smart2 driver to check the return value of
init_device() during probe. If the hardware is unresponsive and initialization
fails, the driver now correctly aborts rather than registering the hwmon
device in an inconsistent state. This safely utilizes an earlier fix that
stops device IO before closing the hardware.

> diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c
> index ff0c0bee0e839..efc78a8f58c88 100644
> --- a/drivers/hwmon/nzxt-smart2.c
> +++ b/drivers/hwmon/nzxt-smart2.c
> @@ -754,7 +754,11 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev,
>  
>  	hid_device_io_start(hdev);
>  
> -	init_device(drvdata, UPDATE_INTERVAL_DEFAULT_MS);
> +	ret = init_device(drvdata, UPDATE_INTERVAL_DEFAULT_MS);
> +	if (ret) {
> +		dev_err(&hdev->dev, "init_device failed: %d\n", ret);
> +		goto out_hw_close;
> +	}
>  
>  	drvdata->hwmon =
>  		hwmon_device_register_with_info(&hdev->dev, "nzxtsmart2", drvdata,

[Severity: High]
This is a pre-existing issue, but does the driver handle device disconnects
safely while blocked in sysfs reads?

If a userspace program is reading a sysfs attribute (like pwm1_enable) and
blocks in nzxt_smart2_hwmon_read() because the device hasn't sent the
required report:

drivers/hwmon/nzxt-smart2.c:nzxt_smart2_hwmon_read() {
    ...
    res = wait_event_interruptible_locked_irq(drvdata->wq,
                                              drvdata->fan_config_received);
    ...
}

If the device is suddenly disconnected, nzxt_smart2_hid_remove() calls
hwmon_device_unregister() without waking up the wait queue or signaling a
disconnect. Will this cause a deadlock in kernfs_drain since the sysfs
thread never wakes up to finish its read?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260804074842.505923-1-fffsqian@163.com?part=1

  reply	other threads:[~2026-08-04  8:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  7:48 [PATCH] hwmon: (nzxt-smart2) Check return value of init_device() in probe Qingshuang Fu
2026-08-04  8:00 ` sashiko-bot [this message]
2026-08-04  8:21   ` Qingshuang Fu
2026-08-04 21:08 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260804080002.570A61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fffsqian@163.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.