Skip to content

Commit c882716

Browse files
windhlgregkh
authored andcommitted
firmware: Hold a reference for of_find_compatible_node()
In of_register_trusted_foundations(), we need to hold the reference returned by of_find_compatible_node() and then use it to call of_node_put() for refcount balance. Signed-off-by: Liang He <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a244ec3 commit c882716

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/linux/firmware/trusted_foundations.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,16 @@ static inline void register_trusted_foundations(
7171

7272
static inline void of_register_trusted_foundations(void)
7373
{
74+
struct device_node *np = of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations");
75+
76+
if (!np)
77+
return;
78+
of_node_put(np);
7479
/*
7580
* If we find the target should enable TF but does not support it,
7681
* fail as the system won't be able to do much anyway
7782
*/
78-
if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations"))
79-
register_trusted_foundations(NULL);
83+
register_trusted_foundations(NULL);
8084
}
8185

8286
static inline bool trusted_foundations_registered(void)

0 commit comments

Comments
 (0)