diff options
author | Liang He <windhl@126.com> | 2022-06-28 10:16:40 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-07-01 10:36:04 +0200 |
commit | c882716b6d411495f221bdd73e9137357c16a3ea (patch) | |
tree | 35adf28c9e06e2eb8fce9e77d7fee4b0d8ff7f2c | |
parent | a244ec3640e0dfe90f31750033433cb2c99446e8 (diff) | |
download | lwn-c882716b6d411495f221bdd73e9137357c16a3ea.tar.gz lwn-c882716b6d411495f221bdd73e9137357c16a3ea.zip |
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 <windhl@126.com>
Link: https://lore.kernel.org/r/20220628021640.4015-1-windhl@126.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | include/linux/firmware/trusted_foundations.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/firmware/trusted_foundations.h b/include/linux/firmware/trusted_foundations.h index be5984bda592..931b6c5c72df 100644 --- a/include/linux/firmware/trusted_foundations.h +++ b/include/linux/firmware/trusted_foundations.h @@ -71,12 +71,16 @@ static inline void register_trusted_foundations( static inline void of_register_trusted_foundations(void) { + struct device_node *np = of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations"); + + if (!np) + return; + of_node_put(np); /* * If we find the target should enable TF but does not support it, * fail as the system won't be able to do much anyway */ - if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations")) - register_trusted_foundations(NULL); + register_trusted_foundations(NULL); } static inline bool trusted_foundations_registered(void) |