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: Re: [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
Date: Tue, 12 Jul 2022 10:58:59 -0600 [thread overview]
Message-ID: <20220712165859.GE1823936-robh@kernel.org> (raw)
In-Reply-To: <4faba661.4c9a.181d26dbd0d.Coremail.windhl@126.com>
On Wed, Jul 06, 2022 at 03:33:36PM +0800, Liang He wrote:
>
>
> At 2022-07-05 22:45:27, "Rob Herring" <robh@kernel.org> wrote:
> >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
>
> Hi, Rob.
>
> After I carefully read the implementation of of_for_each_phandle() and of_parse_phandle(),
> I think it is better to keep current coding style as it will change a lot of current code.
>
> Besides, the loop index 'i' will be used in following of_reserved_mem_device_init_by_idx(), so
> I cannot give a simple and correct way to use of_for_each_phandle().
Ah, okay. I've applied this now. Thanks.
Rob
prev parent reply other threads:[~2022-07-12 16:59 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
2022-07-06 1:14 ` Liang He
2022-07-06 7:33 ` Liang He
2022-07-12 16:58 ` Rob Herring [this message]
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=20220712165859.GE1823936-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).