devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Liang He <windhl@126.com>
Cc: frowand.list@gmail.com, devicetree@vger.kernel.org, linmq006@gmail.com
Subject: Re: [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
Date: Tue, 5 Jul 2022 08:45:27 -0600	[thread overview]
Message-ID: <20220705144527.GA2048024-robh@kernel.org> (raw)
In-Reply-To: <20220702014449.263772-1-windhl@126.com>

On Sat, Jul 02, 2022 at 09:44:49AM +0800, Liang He wrote:
> We should use of_node_put() for the reference 'node' returned by
> of_parse_phandle() which will increase the refcount.
> 
> Fixes: fec9b625095f ("of: Add plumbing for restricted DMA pool")
> Co-authored-by: Miaoqian Lin <linmq006@gmail.com>
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  drivers/of/device.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 874f031442dc..75b6cbffa755 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -81,8 +81,11 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
>  		 * restricted-dma-pool region is allowed.
>  		 */
>  		if (of_device_is_compatible(node, "restricted-dma-pool") &&
> -		    of_device_is_available(node))
> +		    of_device_is_available(node)) {
> +			of_node_put(node);
>  			break;
> +		}
> +		of_node_put(node);

This should be converted to use of_for_each_phandle() iterator instead. 
That takes care of the put here (but not in the break).

Rob

  reply	other threads:[~2022-07-05 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-02  1:44 [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer Liang He
2022-07-05 14:45 ` Rob Herring [this message]
2022-07-06  1:14   ` Liang He
2022-07-06  7:33   ` Liang He
2022-07-12 16:58     ` Rob Herring

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=20220705144527.GA2048024-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linmq006@gmail.com \
    --cc=windhl@126.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;
as well as URLs for NNTP newsgroup(s).