Skip to contentSkip to conversation

of: property: decrement node refcount in of_fwnode_get_reference_args()

PATCH Applied Yang Yingliang 2 participants 2 messages Nov 21, 2022 – Nov 22, 2022 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 of: property: decrement node refcount in of_fwnode_get_reference_args()

In of_fwnode_get_reference_args(), the refcount of of_args.np has been incremented in the case of successful return from of_parse_phandle_with_args() or of_parse_phandle_with_fixed_args().

Decrement the refcount if of_args is not returned to the caller of of_fwnode_get_reference_args().

Fixes 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args")

---
v1 -> v3:
Update title and commit message that suggested by Frank.

---
 drivers/of/property.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/of/property.c +3 -1
index 967f79b59016..134cfc980b70 100644
@@ -993,8 +993,10 @@ of_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
 						       nargs, index, &of_args);
 	if (ret < 0)
 		return ret;
-	if (!args)
+	if (!args) {
+		of_node_put(of_args.np);
 		return 0;
+	}
 
 	args->nargs = of_args.args_count;
 	args->fwnode = of_fwnode_handle(of_args.np);
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 11 lines · Yang Yingliang

In of_fwnode_get_reference_args(), the refcount of of_args.np has been incremented in the case of successful return from of_parse_phandle_with_args() or of_parse_phandle_with_fixed_args().

Decrement the refcount if of_args is not returned to the caller of of_fwnode_get_reference_args().

Fixes 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args")
Quoted 7 lines

---
v1 -> v3:
Update title and commit message that suggested by Frank.

---
 drivers/of/property.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks!