]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mfd: core: Increment of_node's refcount before linking it to the platform device
authorBastien Curutchet <bastien.curutchet@bootlin.com>
Wed, 20 Aug 2025 14:21:13 +0000 (16:21 +0200)
committerLee Jones <lee@kernel.org>
Wed, 1 Oct 2025 09:28:37 +0000 (10:28 +0100)
When an MFD device is added, a platform_device is allocated. If this
device is linked to a DT description, the corresponding OF node is linked
to the new platform device but the OF node's refcount isn't incremented.
As of_node_put() is called during the platform device release, it leads
to a refcount underflow.

Call of_node_get() to increment the OF node's refcount when the node is
linked to the newly created platform device.

Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
Link: https://lore.kernel.org/r/20250820-mfd-refcount-v1-1-6dcb5eb41756@bootlin.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/mfd-core.c

index 76bd316a50afc5c07ff2a3303c4363b16d0bc023..7d14a1e7631ee8d5e91b228a07b2d05695e41b6e 100644 (file)
@@ -131,6 +131,7 @@ allocate_of_node:
        of_entry->np = np;
        list_add_tail(&of_entry->list, &mfd_of_node_list);
 
+       of_node_get(np);
        device_set_node(&pdev->dev, of_fwnode_handle(np));
 #endif
        return 0;