lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230812122411.3410399-1-peng.fan@oss.nxp.com>
Date:   Sat, 12 Aug 2023 20:24:11 +0800
From:   "Peng Fan (OSS)" <peng.fan@....nxp.com>
To:     robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
        conor+dt@...nel.org, frowand.list@...il.com,
        andriy.shevchenko@...ux.intel.com, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     Peng Fan <peng.fan@....com>
Subject: [PATCH] of/platform: increase refcount of fwnode

From: Peng Fan <peng.fan@....com>

commit 0f8e5651095b
("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.

Fixes: 0f8e5651095b ("of/platform: Propagate firmware node by calling device_set_node()")
Signed-off-by: Peng Fan <peng.fan@....com>
---
 drivers/of/platform.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 0c3475e7d2ff..4659ff5a79c8 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -113,6 +113,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 				  const char *bus_id,
 				  struct device *parent)
 {
+	struct fwnode_handle *fwnode = of_fwnode_handle(np);
 	struct platform_device *dev;
 	int rc, i, num_reg = 0;
 	struct resource *res;
@@ -141,7 +142,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	}
 
 	/* setup generic device info */
-	device_set_node(&dev->dev, of_fwnode_handle(np));
+	device_set_node(&dev->dev, fwnode_handle_get(fwnode));
 	dev->dev.parent = parent ? : &platform_bus;
 
 	if (bus_id)
@@ -221,6 +222,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
 						 void *platform_data,
 						 struct device *parent)
 {
+	struct fwnode_handle *fwnode = of_fwnode_handle(node);
 	struct amba_device *dev;
 	int ret;
 
@@ -239,7 +241,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
 	dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
 
 	/* setup generic device info */
-	device_set_node(&dev->dev, of_fwnode_handle(node));
+	device_set_node(&dev->dev, fwnode_handle_get(fwnode));
 	dev->dev.parent = parent ? : &platform_bus;
 	dev->dev.platform_data = platform_data;
 	if (bus_id)
-- 
2.37.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ