Skip to content

Commit ff63b62

Browse files
lucasdemarchirafaeljw
authored andcommitted
thermal: core: Delay exposing sysfs interface
There's a race between initializing the governor and userspace accessing the sysfs interface. From time to time the Intel graphics CI shows this signature: <1>[] #PF: error_code(0x0000) - not-present page <6>[] PGD 0 P4D 0 <4>[] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI <4>[] CPU: 3 UID: 0 PID: 562 Comm: thermald Not tainted 6.14.0-rc4-CI_DRM_16208-g7e37396f86d8+ #1 <4>[] Hardware name: Intel Corporation Twin Lake Client Platform/AlderLake-N LP5 RVP, BIOS TWLNFWI1.R00.5222.A01.2405290634 05/29/2024 <4>[] RIP: 0010:policy_show+0x1a/0x40 thermald tries to read the policy file between the sysfs files being created and the governor set by thermal_set_governor(), which causes the NULL pointer dereference. Similarly to the hwmon interface, delay exposing the sysfs files to when the governor is already set. Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13655 Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://patch.msgid.link/20250307-thermal-sysfs-race-v1-1-8a3d4d4ac9c4@intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent f6e221e commit ff63b62

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/thermal/thermal_core.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,26 +1589,26 @@ thermal_zone_device_register_with_trips(const char *type,
15891589

15901590
tz->state = TZ_STATE_FLAG_INIT;
15911591

1592+
result = dev_set_name(&tz->device, "thermal_zone%d", tz->id);
1593+
if (result)
1594+
goto remove_id;
1595+
1596+
thermal_zone_device_init(tz);
1597+
1598+
result = thermal_zone_init_governor(tz);
1599+
if (result)
1600+
goto remove_id;
1601+
15921602
/* sys I/F */
15931603
/* Add nodes that are always present via .groups */
15941604
result = thermal_zone_create_device_groups(tz);
15951605
if (result)
15961606
goto remove_id;
15971607

1598-
result = dev_set_name(&tz->device, "thermal_zone%d", tz->id);
1599-
if (result) {
1600-
thermal_zone_destroy_device_groups(tz);
1601-
goto remove_id;
1602-
}
1603-
thermal_zone_device_init(tz);
16041608
result = device_register(&tz->device);
16051609
if (result)
16061610
goto release_device;
16071611

1608-
result = thermal_zone_init_governor(tz);
1609-
if (result)
1610-
goto unregister;
1611-
16121612
if (!tz->tzp || !tz->tzp->no_hwmon) {
16131613
result = thermal_add_hwmon_sysfs(tz);
16141614
if (result)

0 commit comments

Comments
 (0)