of/base: release the node correctly in of_parse_phandle_with_args()
Call of_node_put() only when the out_args is NULL on success,
or the node's reference count will not be correct because the caller
will call of_node_put() again.
Signed-off-by: Tang Yuantian <[email protected]>
[grant.likely: tightened up the patch]
Signed-off-by: Grant Likely <[email protected]>
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 321d3ef0..e77e7198 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1166,11 +1166,11 @@
out_args->args_count = count;
for (i = 0; i < count; i++)
out_args->args[i] = be32_to_cpup(list++);
+ } else {
+ of_node_put(node);
}
/* Found it! return success */
- if (node)
- of_node_put(node);
return 0;
}