Re: [PATCH] thermal/core: Fix double device initialization

From: Daniel Lezcano

Date: Mon May 25 2026 - 11:47:37 EST


On 5/25/26 17:29, Rafael J. Wysocki wrote:
On Mon, May 25, 2026 at 5:16 PM Daniel Lezcano
<daniel.lezcano@xxxxxxxxxx> wrote:

In the previous change splitting the cooling device register function,
the device initialization was mistakenly added in the move.

This change is wrong because the device is registered with the
function device_register() which does device_initialize() and then
device_add(). That results in a double initialization and a message in
logs:

[ 1.531290] kobject: kobject (0000000053ba73b2): tried to init an initialized object, something is seriously wrong.
[ 1.531293] CPU: 9 UID: 0 PID: 420 Comm: kworker/u50:3 Not tainted 7.1.0-rc1+ #48 PREEMPT(lazy)
[ 1.531294] Hardware name: LENOVO 21N10007UK/21N10007UK, BIOS N42ET38W (1.12 ) 05/29/2024
[ 1.531295] Workqueue: events_unbound deferred_probe_work_func
[ 1.531298] Call trace:
[ 1.531298] show_stack+0x24/0x50 (C)
[ 1.531301] dump_stack_lvl+0x80/0xc0
[ 1.531303] kobject_init+0xc0/0xd8
[ 1.531305] device_initialize+0x3c/0x140
[ 1.531308] device_register+0x20/0x48
[ 1.531310] thermal_cooling_device_add+0xe0/0x208
[ 1.531311] thermal_of_cooling_device_register+0x54/0xa0
[ 1.531313] __cpufreq_cooling_register+0x1e0/0x368
[ 1.531315] of_cpufreq_cooling_register+0x64/0xe0
[ 1.531316] cpufreq_online+0xa6c/0xef0
[ 1.531317] cpufreq_add_dev+0x108/0x180
[ 1.531318] subsys_interface_register+0x138/0x168
[ 1.531320] cpufreq_register_driver+0x1b8/0x390

Fix by just removing the added line.

Fixes: 13f4e660a126 ("thermal/core: Split __thermal_cooling_device_register() into two functions")

In this commit, the device_register() has been replaced with
device_add(), so the problem above should not trigger.

Which kernel have you tested?

Ah, right, I did the test on a branch having the patch "Split __thermal_cooling_device_register()" but without your changes where device_register() is replaced with device_add().

Everything ok then :)