]> Git Repo - linux.git/blobdiff - lib/vsprintf.c
Merge tag 'x86-cleanups-2024-01-08' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / lib / vsprintf.c
index 3e3733a7084fb70156e59e89443654e199f14442..552738f14275a742fbdff8e876b42b3d850d87fb 100644 (file)
@@ -2111,15 +2111,20 @@ char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf,
 
        /* Loop starting from the root node to the current node. */
        for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) {
-               struct fwnode_handle *__fwnode =
-                       fwnode_get_nth_parent(fwnode, depth);
+               /*
+                * Only get a reference for other nodes (i.e. parent nodes).
+                * fwnode refcount may be 0 here.
+                */
+               struct fwnode_handle *__fwnode = depth ?
+                       fwnode_get_nth_parent(fwnode, depth) : fwnode;
 
                buf = string(buf, end, fwnode_get_name_prefix(__fwnode),
                             default_str_spec);
                buf = string(buf, end, fwnode_get_name(__fwnode),
                             default_str_spec);
 
-               fwnode_handle_put(__fwnode);
+               if (depth)
+                       fwnode_handle_put(__fwnode);
        }
 
        return buf;
This page took 0.035933 seconds and 4 git commands to generate.