summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-12-27 15:41:04 +0100
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-12-27 15:41:04 +0100
commit4ccdaba5ab560862f89d1d971fbcc2ef424e1867 (patch)
treea7931e13df9cc887017eaa143b4dac66de959d90 /lib/vsprintf.c
parent1cdc605c7d70a390ff75a814a26c6f45d75778be (diff)
parent861deac3b092f37b2c5e6871732f3e11486f7082 (diff)
Merge tag 'v6.7-rc7' into gpio/for-next
Linux 6.7-rc7
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 3e3733a7084f..552738f14275 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -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;