All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] v4l: xilinx-vipp: Fix refcount leak in xvip_graph_dma_init
@ 2022-06-01  4:25 ` Miaoqian Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Miaoqian Lin @ 2022-06-01  4:25 UTC (permalink / raw)
  To: Hyun Kwon, Laurent Pinchart, Mauro Carvalho Chehab, Michal Simek,
	Radhey Shyam Pandey, Hans Verkuil, linux-media, linux-arm-kernel,
	linux-kernel
  Cc: linmq006

of_get_child_by_name() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/media/platform/xilinx/xilinx-vipp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index f34f8b077e03..415579b63737 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -483,10 +483,12 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
 		ret = xvip_graph_dma_init_one(xdev, port);
 		if (ret < 0) {
 			of_node_put(port);
+			of_node_put(ports);
 			return ret;
 		}
 	}
 
+	of_node_put(ports);
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] v4l: xilinx-vipp: Fix refcount leak in xvip_graph_dma_init
@ 2022-06-01  4:25 ` Miaoqian Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Miaoqian Lin @ 2022-06-01  4:25 UTC (permalink / raw)
  To: Hyun Kwon, Laurent Pinchart, Mauro Carvalho Chehab, Michal Simek,
	Radhey Shyam Pandey, Hans Verkuil, linux-media, linux-arm-kernel,
	linux-kernel
  Cc: linmq006

of_get_child_by_name() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/media/platform/xilinx/xilinx-vipp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index f34f8b077e03..415579b63737 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -483,10 +483,12 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
 		ret = xvip_graph_dma_init_one(xdev, port);
 		if (ret < 0) {
 			of_node_put(port);
+			of_node_put(ports);
 			return ret;
 		}
 	}
 
+	of_node_put(ports);
 	return 0;
 }
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] v4l: xilinx-vipp: Fix refcount leak in xvip_graph_dma_init
  2022-06-01  4:25 ` Miaoqian Lin
@ 2022-06-01  7:34   ` Laurent Pinchart
  -1 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2022-06-01  7:34 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Hyun Kwon, Mauro Carvalho Chehab, Michal Simek,
	Radhey Shyam Pandey, Hans Verkuil, linux-media, linux-arm-kernel,
	linux-kernel

Hi Lin,

Thank you for the patch.

On Wed, Jun 01, 2022 at 08:25:14AM +0400, Miaoqian Lin wrote:
> of_get_child_by_name() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
> 
> Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/media/platform/xilinx/xilinx-vipp.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f34f8b077e03..415579b63737 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -483,10 +483,12 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
>  		ret = xvip_graph_dma_init_one(xdev, port);
>  		if (ret < 0) {
>  			of_node_put(port);
> +			of_node_put(ports);
>  			return ret;
>  		}
>  	}
>  
> +	of_node_put(ports);

We could possibly simplify this a little bit by initializing ret to 0
when declaring it, replacing the "return ret" above by a break, and
returning ret below. This would remove the need for the first
of_node_put(ports) call above.

If you think that's a good idea I can make that change when applying
this patch to my tree, otherwise I'll take it as-is.

In either case,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	return 0;
>  }
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] v4l: xilinx-vipp: Fix refcount leak in xvip_graph_dma_init
@ 2022-06-01  7:34   ` Laurent Pinchart
  0 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2022-06-01  7:34 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Hyun Kwon, Mauro Carvalho Chehab, Michal Simek,
	Radhey Shyam Pandey, Hans Verkuil, linux-media, linux-arm-kernel,
	linux-kernel

Hi Lin,

Thank you for the patch.

On Wed, Jun 01, 2022 at 08:25:14AM +0400, Miaoqian Lin wrote:
> of_get_child_by_name() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
> 
> Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/media/platform/xilinx/xilinx-vipp.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f34f8b077e03..415579b63737 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -483,10 +483,12 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
>  		ret = xvip_graph_dma_init_one(xdev, port);
>  		if (ret < 0) {
>  			of_node_put(port);
> +			of_node_put(ports);
>  			return ret;
>  		}
>  	}
>  
> +	of_node_put(ports);

We could possibly simplify this a little bit by initializing ret to 0
when declaring it, replacing the "return ret" above by a break, and
returning ret below. This would remove the need for the first
of_node_put(ports) call above.

If you think that's a good idea I can make that change when applying
this patch to my tree, otherwise I'll take it as-is.

In either case,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	return 0;
>  }
>  

-- 
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] v4l: xilinx-vipp: Fix refcount leak in xvip_graph_dma_init
  2022-06-01  7:34   ` Laurent Pinchart
@ 2022-06-01  8:32     ` Miaoqian Lin
  -1 siblings, 0 replies; 6+ messages in thread
From: Miaoqian Lin @ 2022-06-01  8:32 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Hyun Kwon, Mauro Carvalho Chehab, Michal Simek,
	Radhey Shyam Pandey, Hans Verkuil, linux-media, linux-arm-kernel,
	linux-kernel, Miaoqian Lin

Hi, Laurent

On 2022/6/1 15:34, Laurent Pinchart wrote:
> Hi Lin,
>
> Thank you for the patch.
>
> On Wed, Jun 01, 2022 at 08:25:14AM +0400, Miaoqian Lin wrote:
>> of_get_child_by_name() returns a node pointer with refcount
>> incremented, we should use of_node_put() on it when not need anymore.
>> Add missing of_node_put() to avoid refcount leak.
>>
>> Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>> ---
>>  drivers/media/platform/xilinx/xilinx-vipp.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
>> index f34f8b077e03..415579b63737 100644
>> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
>> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
>> @@ -483,10 +483,12 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
>>  		ret = xvip_graph_dma_init_one(xdev, port);
>>  		if (ret < 0) {
>>  			of_node_put(port);
>> +			of_node_put(ports);
>>  			return ret;
>>  		}
>>  	}
>>  
>> +	of_node_put(ports);
> We could possibly simplify this a little bit by initializing ret to 0
> when declaring it, replacing the "return ret" above by a break, and
> returning ret below. This would remove the need for the first
> of_node_put(ports) call above.
>
> If you think that's a good idea I can make that change when applying
> this patch to my tree, otherwise I'll take it as-is.
Thanks for your review, I think your idea is good, we can do that to simplify code.
> In either case,
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>>  	return 0;
>>  }
>>  

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] v4l: xilinx-vipp: Fix refcount leak in xvip_graph_dma_init
@ 2022-06-01  8:32     ` Miaoqian Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Miaoqian Lin @ 2022-06-01  8:32 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Hyun Kwon, Mauro Carvalho Chehab, Michal Simek,
	Radhey Shyam Pandey, Hans Verkuil, linux-media, linux-arm-kernel,
	linux-kernel, Miaoqian Lin

Hi, Laurent

On 2022/6/1 15:34, Laurent Pinchart wrote:
> Hi Lin,
>
> Thank you for the patch.
>
> On Wed, Jun 01, 2022 at 08:25:14AM +0400, Miaoqian Lin wrote:
>> of_get_child_by_name() returns a node pointer with refcount
>> incremented, we should use of_node_put() on it when not need anymore.
>> Add missing of_node_put() to avoid refcount leak.
>>
>> Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>> ---
>>  drivers/media/platform/xilinx/xilinx-vipp.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
>> index f34f8b077e03..415579b63737 100644
>> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
>> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
>> @@ -483,10 +483,12 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
>>  		ret = xvip_graph_dma_init_one(xdev, port);
>>  		if (ret < 0) {
>>  			of_node_put(port);
>> +			of_node_put(ports);
>>  			return ret;
>>  		}
>>  	}
>>  
>> +	of_node_put(ports);
> We could possibly simplify this a little bit by initializing ret to 0
> when declaring it, replacing the "return ret" above by a break, and
> returning ret below. This would remove the need for the first
> of_node_put(ports) call above.
>
> If you think that's a good idea I can make that change when applying
> this patch to my tree, otherwise I'll take it as-is.
Thanks for your review, I think your idea is good, we can do that to simplify code.
> In either case,
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>>  	return 0;
>>  }
>>  

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-01  8:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01  4:25 [PATCH] v4l: xilinx-vipp: Fix refcount leak in xvip_graph_dma_init Miaoqian Lin
2022-06-01  4:25 ` Miaoqian Lin
2022-06-01  7:34 ` Laurent Pinchart
2022-06-01  7:34   ` Laurent Pinchart
2022-06-01  8:32   ` Miaoqian Lin
2022-06-01  8:32     ` Miaoqian Lin

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.