* [PATCH] thermal/core: Fix double device initialization
@ 2026-05-25 15:16 Daniel Lezcano
2026-05-25 15:29 ` Rafael J. Wysocki
2026-05-31 9:42 ` kernel test robot
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Lezcano @ 2026-05-25 15:16 UTC (permalink / raw)
To: rafael, daniel.lezcano; +Cc: linux-pm, rui.zhang, lukasz.luba, linux-kernel
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")
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
---
drivers/thermal/thermal_core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 9b9fa51067bd..3cf305ceaf41 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1012,7 +1012,6 @@ static int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void
cdev->updated = false;
cdev->device.class = thermal_class;
cdev->device.release = thermal_cdev_release;
- device_initialize(&cdev->device);
cdev->devdata = devdata;
ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] thermal/core: Fix double device initialization 2026-05-25 15:16 [PATCH] thermal/core: Fix double device initialization Daniel Lezcano @ 2026-05-25 15:29 ` Rafael J. Wysocki 2026-05-25 15:33 ` Rafael J. Wysocki 2026-05-25 15:43 ` Daniel Lezcano 2026-05-31 9:42 ` kernel test robot 1 sibling, 2 replies; 5+ messages in thread From: Rafael J. Wysocki @ 2026-05-25 15:29 UTC (permalink / raw) To: Daniel Lezcano; +Cc: rafael, linux-pm, rui.zhang, lukasz.luba, linux-kernel On Mon, May 25, 2026 at 5:16 PM Daniel Lezcano <daniel.lezcano@kernel.org> 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? > Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org> > --- > drivers/thermal/thermal_core.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 9b9fa51067bd..3cf305ceaf41 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -1012,7 +1012,6 @@ static int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void > cdev->updated = false; > cdev->device.class = thermal_class; > cdev->device.release = thermal_cdev_release; > - device_initialize(&cdev->device); > cdev->devdata = devdata; > > ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id); > -- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal/core: Fix double device initialization 2026-05-25 15:29 ` Rafael J. Wysocki @ 2026-05-25 15:33 ` Rafael J. Wysocki 2026-05-25 15:43 ` Daniel Lezcano 1 sibling, 0 replies; 5+ messages in thread From: Rafael J. Wysocki @ 2026-05-25 15:33 UTC (permalink / raw) To: Daniel Lezcano; +Cc: linux-pm, rui.zhang, lukasz.luba, linux-kernel On Mon, May 25, 2026 at 5:29 PM Rafael J. Wysocki <rafael@kernel.org> wrote: > > On Mon, May 25, 2026 at 5:16 PM Daniel Lezcano > <daniel.lezcano@kernel.org> 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? Moreover, note that removing device_initialize() would break the cleanup path which relies on the device's kobject to be initialized AFAICS. > > Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org> > > --- > > drivers/thermal/thermal_core.c | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > > index 9b9fa51067bd..3cf305ceaf41 100644 > > --- a/drivers/thermal/thermal_core.c > > +++ b/drivers/thermal/thermal_core.c > > @@ -1012,7 +1012,6 @@ static int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void > > cdev->updated = false; > > cdev->device.class = thermal_class; > > cdev->device.release = thermal_cdev_release; > > - device_initialize(&cdev->device); > > cdev->devdata = devdata; > > > > ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id); > > -- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal/core: Fix double device initialization 2026-05-25 15:29 ` Rafael J. Wysocki 2026-05-25 15:33 ` Rafael J. Wysocki @ 2026-05-25 15:43 ` Daniel Lezcano 1 sibling, 0 replies; 5+ messages in thread From: Daniel Lezcano @ 2026-05-25 15:43 UTC (permalink / raw) To: Rafael J. Wysocki, Daniel Lezcano Cc: linux-pm, rui.zhang, lukasz.luba, linux-kernel On 5/25/26 17:29, Rafael J. Wysocki wrote: > On Mon, May 25, 2026 at 5:16 PM Daniel Lezcano > <daniel.lezcano@kernel.org> 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 :) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal/core: Fix double device initialization 2026-05-25 15:16 [PATCH] thermal/core: Fix double device initialization Daniel Lezcano 2026-05-25 15:29 ` Rafael J. Wysocki @ 2026-05-31 9:42 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2026-05-31 9:42 UTC (permalink / raw) To: Daniel Lezcano Cc: oe-lkp, lkp, linux-pm, rafael, daniel.lezcano, rui.zhang, lukasz.luba, linux-kernel, oliver.sang Hello, kernel test robot noticed "RIP:kobject_get" on: commit: 01e1401d1389f3fe2815a3f391cb22224ff1bfb5 ("[PATCH] thermal/core: Fix double device initialization") url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Lezcano/thermal-core-Fix-double-device-initialization/20260525-231836 patch link: https://lore.kernel.org/all/20260525151609.2826121-2-daniel.lezcano@kernel.org/ patch subject: [PATCH] thermal/core: Fix double device initialization in testcase: boot config: x86_64-rhel-9.4-rust compiler: clang-20 test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 32G (please refer to attached dmesg/kmsg for entire log/backtrace) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <oliver.sang@intel.com> | Closes: https://lore.kernel.org/oe-lkp/202605311744.299c79b6-lkp@intel.com [ 0.943552][ T21] ------------[ cut here ]------------ [ 0.945364][ T21] kobject: 'cooling_device0' ((____ptrval____)): is not initialized, yet kobject_get() is being called. [ 0.949812][ T21] WARNING: lib/kobject.c:642 at kobject_get+0x16/0x80, CPU#0: cpuhp/0/21 [ 0.952015][ T21] Modules linked in: [ 0.953029][ T21] CPU: 0 UID: 0 PID: 21 Comm: cpuhp/0 Not tainted 7.1.0-rc4-next-20260522+ #1 PREEMPT(lazy) [ 0.955559][ T21] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 0.958092][ T21] RIP: 0010:kobject_get (kobject.c:640) [ 0.959340][ T21] Code: 66 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 85 ff 74 3a 53 f6 40 3c 01 75 18 48 8d 3d ca c9 26 01 48 8b 30 48 89 c2 48 89 c3 <67> 48 0f b9 3a 48 89 d8 be 01 00 00 00 b9 01 00 00 00 f0 0f c1 48 All code ======== 0: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1) 7: 00 00 00 00 b: 48 89 f8 mov %rdi,%rax e: 48 85 ff test %rdi,%rdi 11: 74 3a je 0x4d 13: 53 push %rbx 14: f6 40 3c 01 testb $0x1,0x3c(%rax) 18: 75 18 jne 0x32 1a: 48 8d 3d ca c9 26 01 lea 0x126c9ca(%rip),%rdi # 0x126c9eb 21: 48 8b 30 mov (%rax),%rsi 24: 48 89 c2 mov %rax,%rdx 27: 48 89 c3 mov %rax,%rbx 2a:* 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction 2f: 48 89 d8 mov %rbx,%rax 32: be 01 00 00 00 mov $0x1,%esi 37: b9 01 00 00 00 mov $0x1,%ecx 3c: f0 lock 3d: 0f .byte 0xf 3e: c1 .byte 0xc1 3f: 48 rex.W Code starting with the faulting instruction =========================================== 0: 67 48 0f b9 3a ud1 (%edx),%rdi 5: 48 89 d8 mov %rbx,%rax 8: be 01 00 00 00 mov $0x1,%esi d: b9 01 00 00 00 mov $0x1,%ecx 12: f0 lock 13: 0f .byte 0xf 14: c1 .byte 0xc1 15: 48 rex.W [ 0.964083][ T21] RSP: 0000:ffffcbf2000bbd80 EFLAGS: 00010246 [ 0.965592][ T21] RAX: ffff8bdb41ce3018 RBX: ffff8bdb41ce3018 RCX: 0000000000000000 [ 0.967573][ T21] RDX: ffff8bdb41ce3018 RSI: ffff8bdb40aba8e0 RDI: ffffffffbe2b18e0 [ 0.969551][ T21] RBP: 00000000ffffffea R08: 0000000000000000 R09: ffffffffbd0448fd [ 0.971541][ T21] R10: ffff8bdb41ce3001 R11: ffffffffbc95ce40 R12: ffff8bdb41ce3000 [ 0.973500][ T21] R13: ffffffffbd3207d0 R14: ffff8bdb41ce3018 R15: ffff8bdb4180b000 [ 0.975475][ T21] FS: 0000000000000000(0000) GS:ffff8be2a1119000(0000) knlGS:0000000000000000 [ 0.977684][ T21] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 0.979292][ T21] CR2: ffff8be27ffff000 CR3: 00000001f3220000 CR4: 00000000000406f0 [ 0.981267][ T21] Call Trace: [ 0.982115][ T21] <TASK> [ 0.982879][ T21] device_add (base/core.c:3798 base/core.c:3578) [ 0.983946][ T21] __thermal_cooling_device_register (thermal/thermal_core.c:1039) [ 0.985496][ T21] acpi_processor_thermal_init (acpi/processor_thermal.c:316) [ 0.986903][ T21] acpi_soft_cpu_online (acpi/processor_driver.c:167) [ 0.988178][ T21] cpuhp_invoke_callback (cpu.c:194) [ 0.989488][ T21] ? smpboot_thread_fn (smpboot.c:?) [ 0.990732][ T21] cpuhp_thread_fun (cpu.c:1109) [ 0.991912][ T21] smpboot_thread_fn (smpboot.c:160) [ 0.993138][ T21] ? smpboot_unregister_percpu_thread (smpboot.c:320) [ 0.994663][ T21] kthread (kthread.c:436) [ 0.995688][ T21] ? kthread_blkcg (kthread.c:1737) [ 0.996817][ T21] ret_from_fork (x86/kernel/process.c:158) [ 0.997947][ T21] ? kthread_blkcg (kthread.c:1737) [ 0.999098][ T21] ret_from_fork_asm (x86/entry/entry_64.S:245) [ 1.000269][ T21] </TASK> [ 1.001042][ T21] ---[ end trace 0000000000000000 ]--- The kernel config and materials to reproduce are available at: https://download.01.org/0day-ci/archive/20260531/202605311744.299c79b6-lkp@intel.com -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-31 9:42 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-25 15:16 [PATCH] thermal/core: Fix double device initialization Daniel Lezcano 2026-05-25 15:29 ` Rafael J. Wysocki 2026-05-25 15:33 ` Rafael J. Wysocki 2026-05-25 15:43 ` Daniel Lezcano 2026-05-31 9:42 ` kernel test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox