From: sashiko-bot@kernel.org
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v1 1/2] Revert "thermal: hwmon: Use extra_groups for adding temperature attributes"
Date: Fri, 31 Jul 2026 13:20:18 +0000 [thread overview]
Message-ID: <20260731132018.CAEC51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <1992232.tdWV9SEqCh@rafael.j.wysocki>
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 <rafael.j.wysocki@intel.com>
Revert "thermal: hwmon: Use extra_groups for adding temperature attributes"
This reverts commit cfb5dc0f60fb because it was depended on by another commit
that turned out to be problematic.
> diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.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_device *tz)
> scnprintf(hwmon->name, THERMAL_HWMON_NAME_LENGTH, "%s_%d", tz->type, tz->id);
> strreplace(hwmon->name, '-', '_');
> hwmon->device = hwmon_device_register_for_thermal(&tz->device,
> - hwmon->name, hwmon,
> - thermal_hwmon_groups);
> + hwmon->name, hwmon);
> if (IS_ERR(hwmon->device)) {
> - int result = PTR_ERR(hwmon->device);
> + result = PTR_ERR(hwmon->device);
> + goto free_mem;
> + }
>
> - kfree(hwmon);
> - return result;
> + temp = &hwmon->tz_temp;
> +
> + temp->tz = tz;
> +
> + temp->temp_input.attr.attr.name = "temp1_input";
> + temp->temp_input.attr.attr.mode = 0444;
> + temp->temp_input.attr.show = temp_input_show;
> + sysfs_attr_init(&temp->temp_input.attr.attr);
> + result = device_create_file(hwmon->device, &temp->temp_input.attr);
[Severity: Medium]
Does this sequence create a race condition with userspace uevents?
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
read the hwmon device directory right away, they might query it before
device_create_file() finishes adding the temp1_input and temp1_crit
attributes.
Could this lead to missing sensor attributes in userspace during device
initialization?
--
Sashiko AI review · https://sashiko.dev/#/patchset/6319276.lOV4Wx5bFT@rafael.j.wysocki?part=1
next prev parent reply other threads:[~2026-07-31 13:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 12:59 [PATCH v1 0/2] thermal: hwmon: Restore automatic hwmon device registration Rafael J. Wysocki
2026-07-31 13:00 ` [PATCH v1 1/2] Revert "thermal: hwmon: Use extra_groups for adding temperature attributes" Rafael J. Wysocki
2026-07-31 13:20 ` sashiko-bot [this message]
2026-07-31 13:01 ` [PATCH v1 2/2] Revert "thermal: hwmon: Register a hwmon device for each thermal zone" Rafael J. Wysocki
2026-07-31 13:19 ` sashiko-bot
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=20260731132018.CAEC51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=rafael@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox