From: Liang He <windhl@126.com>
To: broonie@kernel.org, gregkh@linuxfoundation.org,
ckeepax@opensource.cirrus.com, michal.simek@xilinx.com,
abhyuday.godhasara@xilinx.com, simont@opensource.cirrus.com,
ronak.jain@xilinx.com, peng.fan@nxp.com,
linux-kernel@vger.kernel.org
Cc: windhl@126.com
Subject: [PATCH v2] firmware: Hold a reference for of_find_compatible_node()
Date: Tue, 28 Jun 2022 10:16:40 +0800 [thread overview]
Message-ID: <20220628021640.4015-1-windhl@126.com> (raw)
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>
---
v2: use 'check-and-put' coding style
v1: hold ref returned by of_find_xxx
v1 link: https://lore.kernel.org/all/20220621032625.4078445-1-windhl@126.com/
include/linux/firmware/trusted_foundations.h | 8 ++++++--
1 file 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)
--
2.25.1
reply other threads:[~2022-06-28 2:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220628021640.4015-1-windhl@126.com \
--to=windhl@126.com \
--cc=abhyuday.godhasara@xilinx.com \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=peng.fan@nxp.com \
--cc=ronak.jain@xilinx.com \
--cc=simont@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®