Subject: [next-20220629] kobject warnings during boot

From: Sachin Sant <[email-masked]>
Date: Thu, 30 Jun 2022 17:01:57 +0530

While booting linux-next (5.19.0-rc4-next-20220629) on Power8 non-virtualised
following koject warning is seen:

[    0.000184] clocksource: timebase mult[1f40000] shift[24] registered
[    0.000303] clockevent: decrementer mult[83126e98] shift[32] cpu[0]
[    0.000397] ------------[ cut here ]------------
[    0.000478] kobject: '(null)' ((____ptrval____)): is not initialized, yet kobject_get() is being called.
[    0.000667] WARNING: CPU: 0 PID: 0 at lib/kobject.c:626 kobject_get+0x90/0x100
[    0.000802] Modules linked in:
[    0.000861] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.19.0-rc4-next-20220629 #1
[    0.000995] NIP:  c00000000073b0c0 LR: c00000000073b0bc CTR: c0000000000d33a0
[    0.001120] REGS: c000000002a0f890 TRAP: 0700   Not tainted  (5.19.0-rc4-next-20220629)
[    0.001260] MSR:  9000000002021033 <SF,HV,VEC,ME,IR,DR,RI,LE>  CR: 28008822  XER: 20000000
[    0.001428] CFAR: c00000000014f3a4 IRQMASK: 1
               GPR00: c00000000073b0bc c000000002a0fb30 c000000002a12000 000000000000005c
               GPR04: 00000000ffff7fff c000000002a0f8f0 c000000002a0f8e8 0000000000000000
               GPR08: c000000002826b78 0000000000000000 c000000002566a50 c0000000028e6bb8
               GPR12: 0000000000008800 c000000002d00000 0000000000000003 0000000000000000
               GPR16: 0000000000000000 0000000000000000 0000000000000278 c000000002a4dfe0
               GPR20: c000000002a52238 c000000002a52820 c0000000000d8d60 c000000000fe6e18
               GPR24: 0000000000000000 c000000002a0fe90 c000000000fe6e08 0000000000000000
               GPR28: 0000000000000000 c000000002952e80 c000000ffffc3f10 c000000002952e80
[    0.002681] NIP [c00000000073b0c0] kobject_get+0x90/0x100
[    0.002781] LR [c00000000073b0bc] kobject_get+0x8c/0x100
[    0.002880] Call Trace:
[    0.002925] [c000000002a0fb30] [c00000000073b0bc] kobject_get+0x8c/0x100 (unreliable)
[    0.003071] [c000000002a0fba0] [c00000000087e464] device_add+0xf4/0xb00
[    0.003194] [c000000002a0fc80] [c000000000a7f6e4] of_device_add+0x64/0x80
[    0.003321] [c000000002a0fcb0] [c000000000a800d0] of_platform_device_create_pdata+0xd0/0x1b0
[    0.003476] [c000000002a0fd00] [c00000000201fa44] pnv_get_random_long_early+0x240/0x2e4
[    0.003623] [c000000002a0fe20] [c000000002060c38] random_init+0xc0/0x214
[    0.003749] [c000000002a0fec0] [c0000000020048bc] start_kernel+0x98c/0xbf4
[    0.003878] [c000000002a0ff90] [c00000000000d978] start_here_common+0x1c/0x24
[    0.004008] Instruction dump:
[    0.004063] 4e800020 60000000 60000000 60000000 7c0802a6 3c62fe65 7fe5fb78 3863a8e0
[    0.004216] f8010080 e89f0000 4ba14285 60000000 <0fe00000> 60000000 60000000 60000000
[    0.004372] ---[ end trace 0000000000000000 ]---
[    0.004456] ------------[ cut here ]------------
[    0.004537] refcount_t: addition on 0; use-after-free.
[    0.004645] WARNING: CPU: 0 PID: 0 at lib/refcount.c:25 refcount_warn_saturate+0x164/0x1f0
[    0.004797] Modules linked in:
[    0.004853] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W         5.19.0-rc4-next-20220629 #1
[    0.005010] NIP:  c0000000006e0a54 LR: c0000000006e0a50 CTR: c0000000000d33a0
[    0.005134] REGS: c000000002a0f830 TRAP: 0700   Tainted: G        W          (5.19.0-rc4-next-20220629)

Reverting the following patch helps avoid this warning.

commit f3eac426657d985b97c92fa5f7ae1d43f04721f3
    powerpc/powernv: wire up rng during setup_arch

I have attached the dmesg log.

Thanks
- Sachin