dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
@ 2022-07-15 13:21 Liang He
  2022-07-25 19:39 ` Martin Blumenstingl
  0 siblings, 1 reply; 6+ messages in thread
From: Liang He @ 2022-07-15 13:21 UTC (permalink / raw)
  To: narmstrong, airlied, daniel, khilman, windhl, jbrunet,
	martin.blumenstingl, dri-devel

In this function, there are two refcount leak bugs:
(1) when breaking out of for_each_endpoint_of_node(), we need call
the of_node_put() for the 'ep';
(2) we should call of_node_put() for the reference returned by
of_graph_get_remote_port() when it is not used anymore.

Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/gpu/drm/meson/meson_drv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 1b70938cfd2c..bd4ca11d3ff5 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -115,8 +115,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
 	for_each_endpoint_of_node(dev->of_node, ep) {
 		/* If the endpoint node exists, consider it enabled */
 		remote = of_graph_get_remote_port(ep);
-		if (remote)
+		if (remote) {
+			of_node_put(remote);
+			of_node_put(ep);
 			return true;
+		}
 	}
 
 	return false;
-- 
2.25.1


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

* Re: [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
  2022-07-15 13:21 [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors() Liang He
@ 2022-07-25 19:39 ` Martin Blumenstingl
  2022-07-26  0:59   ` Liang He
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Blumenstingl @ 2022-07-25 19:39 UTC (permalink / raw)
  To: Liang He; +Cc: Neil Armstrong, airlied, khilman, dri-devel, jbrunet

Hello,

On Fri, Jul 15, 2022 at 3:22 PM Liang He <windhl@126.com> wrote:
>
> In this function, there are two refcount leak bugs:
> (1) when breaking out of for_each_endpoint_of_node(), we need call
> the of_node_put() for the 'ep';
> (2) we should call of_node_put() for the reference returned by
> of_graph_get_remote_port() when it is not used anymore.
>
> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
> Signed-off-by: Liang He <windhl@126.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

It's easy for me to miss patches if the linux-amlogic list is not part
of the recipient list.
Can you please re-send this patch and include the linux-amlogic
mailing list (with my acked-by added)? Then it should also show up in
Neil's inbox so he can apply this patch.


Thank you
Martin

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

* Re:Re: [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
  2022-07-25 19:39 ` Martin Blumenstingl
@ 2022-07-26  0:59   ` Liang He
  0 siblings, 0 replies; 6+ messages in thread
From: Liang He @ 2022-07-26  0:59 UTC (permalink / raw)
  To: Martin Blumenstingl; +Cc: Neil Armstrong, airlied, khilman, dri-devel, jbrunet


At 2022-07-26 03:39:17, "Martin Blumenstingl" <martin.blumenstingl@googlemail.com> wrote:
>Hello,
>
>On Fri, Jul 15, 2022 at 3:22 PM Liang He <windhl@126.com> wrote:
>>
>> In this function, there are two refcount leak bugs:
>> (1) when breaking out of for_each_endpoint_of_node(), we need call
>> the of_node_put() for the 'ep';
>> (2) we should call of_node_put() for the reference returned by
>> of_graph_get_remote_port() when it is not used anymore.
>>
>> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
>> Signed-off-by: Liang He <windhl@126.com>
>Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>
>It's easy for me to miss patches if the linux-amlogic list is not part
>of the recipient list.
>Can you please re-send this patch and include the linux-amlogic
>mailing list (with my acked-by added)? Then it should also show up in
>Neil's inbox so he can apply this patch.
>
>
>Thank you
>Martin

Thanks, 

I will do that soon.

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

* Re: [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
  2022-07-26  1:07 Liang He
  2022-08-08  7:43 ` Neil Armstrong
@ 2022-08-08  7:52 ` Neil Armstrong
  1 sibling, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2022-08-08  7:52 UTC (permalink / raw)
  To: airlied, martin.blumenstingl, linux-amlogic, jbrunet, dri-devel,
	Liang He, daniel, khilman
  Cc: Neil Armstrong

Hi,

On Tue, 26 Jul 2022 09:07:22 +0800, Liang He wrote:
> In this function, there are two refcount leak bugs:
> (1) when breaking out of for_each_endpoint_of_node(), we need call
> the of_node_put() for the 'ep';
> (2) we should call of_node_put() for the reference returned by
> of_graph_get_remote_port() when it is not used anymore.
> 
> 
> [...]

Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-fixes)

[1/1] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
      https://cgit.freedesktop.org/drm/drm-misc/commit/?id=91b3c8dbe898df158fd2a84675f3a284ff6666f7

-- 
Neil

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

* Re: [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
  2022-07-26  1:07 Liang He
@ 2022-08-08  7:43 ` Neil Armstrong
  2022-08-08  7:52 ` Neil Armstrong
  1 sibling, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2022-08-08  7:43 UTC (permalink / raw)
  To: Liang He, airlied, daniel, khilman, jbrunet, martin.blumenstingl,
	dri-devel, linux-amlogic

On 26/07/2022 03:07, Liang He wrote:
> In this function, there are two refcount leak bugs:
> (1) when breaking out of for_each_endpoint_of_node(), we need call
> the of_node_put() for the 'ep';
> (2) we should call of_node_put() for the reference returned by
> of_graph_get_remote_port() when it is not used anymore.
> 
> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
> Signed-off-by: Liang He <windhl@126.com>
> Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
>   drivers/gpu/drm/meson/meson_drv.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index 1b70938cfd2c..bd4ca11d3ff5 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -115,8 +115,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
>   	for_each_endpoint_of_node(dev->of_node, ep) {
>   		/* If the endpoint node exists, consider it enabled */
>   		remote = of_graph_get_remote_port(ep);
> -		if (remote)
> +		if (remote) {
> +			of_node_put(remote);
> +			of_node_put(ep);
>   			return true;
> +		}
>   	}
>   
>   	return false;

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

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

* [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
@ 2022-07-26  1:07 Liang He
  2022-08-08  7:43 ` Neil Armstrong
  2022-08-08  7:52 ` Neil Armstrong
  0 siblings, 2 replies; 6+ messages in thread
From: Liang He @ 2022-07-26  1:07 UTC (permalink / raw)
  To: narmstrong, airlied, daniel, khilman, jbrunet,
	martin.blumenstingl, dri-devel, linux-amlogic, windhl

In this function, there are two refcount leak bugs:
(1) when breaking out of for_each_endpoint_of_node(), we need call
the of_node_put() for the 'ep';
(2) we should call of_node_put() for the reference returned by
of_graph_get_remote_port() when it is not used anymore.

Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
Signed-off-by: Liang He <windhl@126.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpu/drm/meson/meson_drv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 1b70938cfd2c..bd4ca11d3ff5 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -115,8 +115,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
 	for_each_endpoint_of_node(dev->of_node, ep) {
 		/* If the endpoint node exists, consider it enabled */
 		remote = of_graph_get_remote_port(ep);
-		if (remote)
+		if (remote) {
+			of_node_put(remote);
+			of_node_put(ep);
 			return true;
+		}
 	}
 
 	return false;
-- 
2.25.1


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

end of thread, other threads:[~2022-08-08  7:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 13:21 [PATCH] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors() Liang He
2022-07-25 19:39 ` Martin Blumenstingl
2022-07-26  0:59   ` Liang He
2022-07-26  1:07 Liang He
2022-08-08  7:43 ` Neil Armstrong
2022-08-08  7:52 ` Neil Armstrong

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).