Skip to content

Commit 7882541

Browse files
MrVanrobherring
authored andcommitted
of/platform: increase refcount of fwnode
commit 0f8e565 ("of/platform: Propagate firmware node by calling device_set_node()") use of_fwnode_handle to replace of_node_get, which introduces a side effect that the refcount is not increased. Then the out of tree jailhouse hypervisor enable/disable test will trigger kernel dump in of_overlay_remove, with the following sequence " of_changeset_revert(&overlay_changeset); of_changeset_destroy(&overlay_changeset); of_overlay_remove(&overlay_id); " So increase the refcount to avoid issues. This patch also release the refcount when releasing amba device to avoid refcount leakage. Fixes: 0f8e565 ("of/platform: Propagate firmware node by calling device_set_node()") Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://lore.kernel.org/r/20230821023928.3324283-2-peng.fan@oss.nxp.com Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 914d9d8 commit 7882541

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/of/platform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
141141
}
142142

143143
/* setup generic device info */
144-
device_set_node(&dev->dev, of_fwnode_handle(np));
144+
device_set_node(&dev->dev, of_fwnode_handle(of_node_get(np)));
145145
dev->dev.parent = parent ? : &platform_bus;
146146

147147
if (bus_id)
@@ -239,7 +239,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
239239
dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
240240

241241
/* setup generic device info */
242-
device_set_node(&dev->dev, of_fwnode_handle(node));
242+
device_set_node(&dev->dev, of_fwnode_handle(of_node_get(node)));
243243
dev->dev.parent = parent ? : &platform_bus;
244244
dev->dev.platform_data = platform_data;
245245
if (bus_id)

0 commit comments

Comments
 (0)