From nobody Sun Apr 26 08:12:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 157B5C43334 for ; Tue, 21 Jun 2022 03:27:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244625AbiFUD1q (ORCPT ); Mon, 20 Jun 2022 23:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242106AbiFUD1n (ORCPT ); Mon, 20 Jun 2022 23:27:43 -0400 Received: from mail-m965.mail.126.com (mail-m965.mail.126.com [123.126.96.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8452517AB9 for ; Mon, 20 Jun 2022 20:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=GzVgp sAUqnpJ4ghJLSX1HCwiVWXy7WhXVh4xCTWMQWw=; b=mON60WB+BgXpYxZnoMQ9B Ry5aKo/xTKKsUzNFtava1WkFeNkmSnlskuRRTDxeM5GP52uyWsyYTW01XuGd9NIs vKnwBAiRJew85bRx0q2yuo26g2eEUK4+ETTPgKwoRNuC7+7MWatKKpG/TOATunSw qOqF+tfJhctaLSysTvhGms= Received: from localhost.localdomain (unknown [124.16.139.61]) by smtp10 (Coremail) with SMTP id NuRpCgAHboJiOrFinEUwFA--.34259S2; Tue, 21 Jun 2022 11:26:28 +0800 (CST) From: Liang He 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: Liang He Subject: [PATCH] firmware: Hold a reference for of_find_compatible_node() Date: Tue, 21 Jun 2022 11:26:25 +0800 Message-Id: <20220621032625.4078445-1-windhl@126.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: NuRpCgAHboJiOrFinEUwFA--.34259S2 X-Coremail-Antispam: 1Uf129KBjvJXoWrKw47Zw1rZr1xGryrGFW7Arb_yoW8JF1rpF n5uayrAayxX3s7ArykCFsayFyfWF4rGF4UGFWUWwn7tr1DJF1ktFW2qFWYyF1vvFW8Ar15 WFyUWw1jga42yr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziF1vfUUUUU= X-Originating-IP: [124.16.139.61] X-CM-SenderInfo: hzlqvxbo6rjloofrz/1tbiuAQnF2JVj9yzfwAAsk Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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/f= irmware/trusted_foundations.h index be5984bda592..399471c2f1c7 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( =20 static inline void of_register_trusted_foundations(void) { + struct device_node *np =3D of_find_compatible_node(NULL, NULL, "tlm,trust= ed-foundations"); + + of_node_put(np); + if (!np) + return; /* * 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); } =20 static inline bool trusted_foundations_registered(void) --=20 2.25.1