summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
authorFrank Rowand <frowand.list@gmail.com>2023-02-13 12:57:00 -0600
committerRob Herring <robh@kernel.org>2023-02-20 15:37:19 -0600
commit23522dd7033ad8dcd818f75469907a8fdac8e8a4 (patch)
treea494397a5ed65f07daceff2ec931022d19199e3a /drivers/of
parent74df14cd301a1433947077e79ce2c610654a32e7 (diff)
downloadlinux-23522dd7033ad8dcd818f75469907a8fdac8e8a4.tar.gz
of: do not use "%pOF" printk format on node with refcount of zero
of_node_release() can not use the "%pOF" printk format to report the node name of a node when the node reference count is zero. This is because the formatter device_node_string() calls fwnode_full_name_string() which indirectly calls of_node_get(). Calling of_node_get() on the node with a zero reference count results in a WARNING and stack trace. When the reference count has been decremented to zero, this function is in the subsequent call path which frees memory related to the node. This commit resolves the unittest EXPECT errors that were created in the previous commmit. Signed-off-by: Frank Rowand <frowand.list@gmail.com> Link: https://lore.kernel.org/r/20230213185702.395776-6-frowand.list@gmail.com Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/dynamic.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index becb80f762c8..dbcbc41f3465 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -329,9 +329,17 @@ void of_node_release(struct kobject *kobj)
{
struct device_node *node = kobj_to_device_node(kobj);
+ /*
+ * can not use '"%pOF", node' in pr_err() calls from this function
+ * because an of_node_get(node) when refcount is already zero
+ * will result in an error and a stack dump
+ */
+
/* We should never be releasing nodes that haven't been detached. */
if (!of_node_check_flag(node, OF_DETACHED)) {
- pr_err("ERROR: Bad of_node_put() on %pOF\n", node);
+
+ pr_err("ERROR: %s() detected bad of_node_put() on %pOF/%s\n",
+ __func__, node->parent, node->full_name);
/*
* of unittests will test this path. Do not print the stack