Re: [PATCH] hwmon: (nzxt-smart2) Check return value of init_device() in probe
[email protected] Tue, 04 Aug 2026 08:00:01 +0000
| Newsgroups | org.kernel.vger.linux-hwmon |
|---|---|
| Message-ID | <[email protected]> |
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 repor= ts without providing a mechanism to break the wait on device disconnect, ca= using the device unbind thread to deadlock. -- --- Patch [1]: [PATCH] hwmon: (nzxt-smart2) Check return value of init_devi= ce() in probe --- commit 18435050bb0408be0aa1e570c7a2976a468d52c0 Author: Qingshuang Fu <[email protected]> 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 initializat= ion 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, > =20 > hid_device_io_start(hdev); > =20 > - init_device(drvdata, UPDATE_INTERVAL_DEFAULT_MS); > + ret =3D init_device(drvdata, UPDATE_INTERVAL_DEFAULT_MS); > + if (ret) { > + dev_err(&hdev->dev, "init_device failed: %d\n", ret); > + goto out_hw_close; > + } > =20 > drvdata->hwmon =3D > 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 =3D 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? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260804074842.5059= [email protected]?part=3D1