Re: Re: [PATCH] of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 06, 2022 at 03:33:36PM +0800, Liang He wrote:
> 
> 
> At 2022-07-05 22:45:27, "Rob Herring" <robh@xxxxxxxxxx> 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@xxxxxxxxx>
> >> Signed-off-by: Liang He <windhl@xxxxxxx>
> >> ---
> >>  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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux