* [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
@ 2022-07-02 1:44 Liang He
2022-07-05 14:45 ` Rob Herring
0 siblings, 1 reply; 5+ messages in thread
From: Liang He @ 2022-07-02 1:44 UTC (permalink / raw)
To: robh+dt, frowand.list, devicetree, windhl, linmq006
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);
}
/*
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
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
0 siblings, 2 replies; 5+ messages in thread
From: Rob Herring @ 2022-07-05 14:45 UTC (permalink / raw)
To: Liang He; +Cc: frowand.list, devicetree, linmq006
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:Re: [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
2022-07-05 14:45 ` Rob Herring
@ 2022-07-06 1:14 ` Liang He
2022-07-06 7:33 ` Liang He
1 sibling, 0 replies; 5+ messages in thread
From: Liang He @ 2022-07-06 1:14 UTC (permalink / raw)
To: Rob Herring; +Cc: frowand.list, devicetree, linmq006
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
Thanks, Rob.
We try to rework the loop using of_for_each_phandle().
Thanks,
Liang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:Re: [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
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
1 sibling, 1 reply; 5+ messages in thread
From: Liang He @ 2022-07-06 7:33 UTC (permalink / raw)
To: Rob Herring; +Cc: frowand.list, devicetree, linmq006
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
2022-07-06 7:33 ` Liang He
@ 2022-07-12 16:58 ` Rob Herring
0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2022-07-12 16:58 UTC (permalink / raw)
To: Liang He; +Cc: frowand.list, devicetree, linmq006
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-12 16:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).