Re: [PATCH v1 1/2] Revert "thermal: hwmon: Use extra_groups for adding temperature attributes"
[email protected] Fri, 31 Jul 2026 13:20:18 +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: - [Medium] Adding sysfs attributes via `device_create_file()` after device = registration creates a race condition with userspace uevents. -- --- Patch [1]: [PATCH v1 1/2] Revert "thermal: hwmon: Use extra_groups for = adding temperature attributes" --- commit fd1537461eb002e63315e0164251174bf300f7cc Author: Rafael J. Wysocki <[email protected]> Revert "thermal: hwmon: Use extra_groups for adding temperature attributes" This reverts commit cfb5dc0f60fb because it was depended on by another comm= it that turned out to be problematic. > diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hw= mon.c > index 386dfb9f559e3..223ae1571655b 100644 > --- a/drivers/thermal/thermal_hwmon.c > +++ b/drivers/thermal/thermal_hwmon.c [ ... ] > @@ -120,13 +114,35 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_dev= ice *tz) > scnprintf(hwmon->name, THERMAL_HWMON_NAME_LENGTH, "%s_%d", tz->type, tz= ->id); > strreplace(hwmon->name, '-', '_'); > hwmon->device =3D hwmon_device_register_for_thermal(&tz->device, > - hwmon->name, hwmon, > - thermal_hwmon_groups); > + hwmon->name, hwmon); > if (IS_ERR(hwmon->device)) { > - int result =3D PTR_ERR(hwmon->device); > + result =3D PTR_ERR(hwmon->device); > + goto free_mem; > + } > =20 > - kfree(hwmon); > - return result; > + temp =3D &hwmon->tz_temp; > + > + temp->tz =3D tz; > + > + temp->temp_input.attr.attr.name =3D "temp1_input"; > + temp->temp_input.attr.attr.mode =3D 0444; > + temp->temp_input.attr.show =3D temp_input_show; > + sysfs_attr_init(&temp->temp_input.attr.attr); > + result =3D device_create_file(hwmon->device, &temp->temp_input.attr); [Severity: Medium] Does this sequence create a race condition with userspace uevents?=20 When thermal_add_hwmon_sysfs() calls hwmon_device_register_for_thermal(), the device is registered and the KOBJ_ADD uevent fires immediately. If userspace monitoring daemons or udev rules respond to this uevent and=20 read the hwmon device directory right away, they might query it before=20 device_create_file() finishes adding the temp1_input and temp1_crit=20 attributes. Could this lead to missing sensor attributes in userspace during device initialization? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/6319276.lOV4Wx5bFT@= rafael.j.wysocki?part=3D1