[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yrm6JztPuqYmKlKF@kroah.com>
Date: Mon, 27 Jun 2022 16:09:43 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Liang He <windhl@....com>
Cc: broonie@...nel.org, ckeepax@...nsource.cirrus.com,
michal.simek@...inx.com, abhyuday.godhasara@...inx.com,
simont@...nsource.cirrus.com, ronak.jain@...inx.com,
peng.fan@....com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] firmware: Hold a reference for of_find_compatible_node()
On Tue, Jun 21, 2022 at 11:26:25AM +0800, Liang He wrote:
> 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@....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..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(
>
> static inline void of_register_trusted_foundations(void)
> {
> + struct device_node *np = of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations");
> +
> + of_node_put(np);
> + if (!np)
While this is technically correct, you are now checking to see if this
points to a memory location that you no longer know what it really
belongs to. C will let you do this, but it might be nicer to fix it up
properly so it doesn't look like this.
thanks,
greg k-h
Powered by blists - more mailing lists