Skip to content

Commit dc70eb8

Browse files
Tropicaoyilunxu1984
authored andcommitted
fpga: bridge: properly initialize bridge device before populating children
The current code path can lead to warnings because of uninitialized device, which contains, as a consequence, uninitialized kobject. The uninitialized device is passed to of_platform_populate, which will at some point, while creating child device, try to get a reference on uninitialized parent, resulting in the following warning: kobject: '(null)' ((ptrval)): is not initialized, yet kobject_get() is being called. The warning is observed after migrating a kernel 5.10.x to 6.1.x. Reverting commit 0d70af3 ("fpga: bridge: Use standard dev_release for class driver") seems to remove the warning. This commit aggregates device_initialize() and device_add() into device_register() but this new call is done AFTER of_platform_populate Fixes: 0d70af3 ("fpga: bridge: Use standard dev_release for class driver") Signed-off-by: Alexis Lothoré <[email protected]> Acked-by: Xu Yilun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Xu Yilun <[email protected]>
1 parent d2b727c commit dc70eb8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/fpga/fpga-bridge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ fpga_bridge_register(struct device *parent, const char *name,
363363
bridge->dev.parent = parent;
364364
bridge->dev.of_node = parent->of_node;
365365
bridge->dev.id = id;
366-
of_platform_populate(bridge->dev.of_node, NULL, NULL, &bridge->dev);
367366

368367
ret = dev_set_name(&bridge->dev, "br%d", id);
369368
if (ret)
@@ -375,6 +374,8 @@ fpga_bridge_register(struct device *parent, const char *name,
375374
return ERR_PTR(ret);
376375
}
377376

377+
of_platform_populate(bridge->dev.of_node, NULL, NULL, &bridge->dev);
378+
378379
return bridge;
379380

380381
error_device:

0 commit comments

Comments
 (0)