Skip to content

Commit c0f65a7

Browse files
committed
Merge tag 'printk-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux
Pull printk fix from Petr Mladek: - Prevent refcount warning from code releasing a fwnode * tag 'printk-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: lib/vsprintf: Fix %pfwf when current node refcount == 0
2 parents 5414aea + 5c47251 commit c0f65a7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/vsprintf.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,15 +2111,20 @@ char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf,
21112111

21122112
/* Loop starting from the root node to the current node. */
21132113
for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) {
2114-
struct fwnode_handle *__fwnode =
2115-
fwnode_get_nth_parent(fwnode, depth);
2114+
/*
2115+
* Only get a reference for other nodes (i.e. parent nodes).
2116+
* fwnode refcount may be 0 here.
2117+
*/
2118+
struct fwnode_handle *__fwnode = depth ?
2119+
fwnode_get_nth_parent(fwnode, depth) : fwnode;
21162120

21172121
buf = string(buf, end, fwnode_get_name_prefix(__fwnode),
21182122
default_str_spec);
21192123
buf = string(buf, end, fwnode_get_name(__fwnode),
21202124
default_str_spec);
21212125

2122-
fwnode_handle_put(__fwnode);
2126+
if (depth)
2127+
fwnode_handle_put(__fwnode);
21232128
}
21242129

21252130
return buf;

0 commit comments

Comments
 (0)