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]
Date:   Fri,  6 Nov 2020 15:07:47 +0000
From:   Mark Brown <broonie@...nel.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J . Wysocki" <rafael@...nel.org>
Cc:     Daniel Mentz <danielmentz@...gle.com>,
        Saravana Kannan <saravanak@...gle.com>,
        linux-kernel@...r.kernel.org, Mark Brown <broonie@...nel.org>
Subject: [PATCH RFC] driver core: Ensure DT devices always have fwnode set

Currently the fwnode API and things that rely on it like fw_devlink will
not reliably work for devices created from DT since each subsystem that
creates devices must individually set dev->fwnode in addition to setting
dev->of_node, currently a number of subsystems don't do so. Ensure that
this can't get missed by setting fwnode from of_node if it's not
previously been set by the subsystem.

Reported-by: Saravana Kannan <saravanak@...gle.com>
Signed-off-by: Mark Brown <broonie@...nel.org>
---

*Very* minimally tested.

 drivers/base/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index d661ada1518f..658626bafd76 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2864,6 +2864,10 @@ int device_add(struct device *dev)
 	if (parent && (dev_to_node(dev) == NUMA_NO_NODE))
 		set_dev_node(dev, dev_to_node(parent));
 
+	/* ensure that fwnode is set up */
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node && !dev->fwnode)
+		dev->fwnode = of_fwnode_handle(dev->of_node);
+
 	/* first, register with generic layer. */
 	/* we require the name to be set before, and pass NULL */
 	error = kobject_add(&dev->kobj, dev->kobj.parent, NULL);
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ