From: "Liang He" <windhl@126.com>
To: "Rob Herring" <robh@kernel.org>
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: Wed, 6 Jul 2022 15:33:36 +0800 (CST) [thread overview]
Message-ID: <4faba661.4c9a.181d26dbd0d.Coremail.windhl@126.com> (raw)
In-Reply-To: <20220705144527.GA2048024-robh@kernel.org>
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().
Thanks,
Liang
next prev parent reply other threads:[~2022-07-06 7:33 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 [this message]
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=4faba661.4c9a.181d26dbd0d.Coremail.windhl@126.com \
--to=windhl@126.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linmq006@gmail.com \
--cc=robh@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.