All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08  2:58 ` Wen Yang
  0 siblings, 0 replies; 14+ messages in thread
From: Wen Yang @ 2019-04-08  2:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Wen Yang, Neil Armstrong, David Airlie, Daniel Vetter,
	Kevin Hilman, dri-devel, linux-amlogic, linux-arm-kernel,
	Markus Elfring

The call to of_graph_get_remote_port returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/gpu/drm/meson/meson_dw_hdmi.c:725:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 722, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: Markus Elfring <Markus.Elfring@web.de>
---
v2->v1: convert a if statement into a ternary statement.

 drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index 563953e..826b98b 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
 
 	/* If the endpoint node exists, consider it enabled */
 	remote = of_graph_get_remote_port(ep);
-	if (remote) {
-		of_node_put(ep);
-		return true;
-	}
-
 	of_node_put(ep);
 	of_node_put(remote);
 
-	return false;
+	return remote ? true : false;
 }
 
 static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
-- 
2.9.5


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

* [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08  2:58 ` Wen Yang
  0 siblings, 0 replies; 14+ messages in thread
From: Wen Yang @ 2019-04-08  2:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Neil Armstrong, David Airlie, Kevin Hilman, dri-devel,
	Markus Elfring, Daniel Vetter, linux-amlogic, Wen Yang,
	linux-arm-kernel

The call to of_graph_get_remote_port returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/gpu/drm/meson/meson_dw_hdmi.c:725:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 722, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: Markus Elfring <Markus.Elfring@web.de>
---
v2->v1: convert a if statement into a ternary statement.

 drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index 563953e..826b98b 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
 
 	/* If the endpoint node exists, consider it enabled */
 	remote = of_graph_get_remote_port(ep);
-	if (remote) {
-		of_node_put(ep);
-		return true;
-	}
-
 	of_node_put(ep);
 	of_node_put(remote);
 
-	return false;
+	return remote ? true : false;
 }
 
 static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
-- 
2.9.5


_______________________________________________
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] 14+ messages in thread

* [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08  2:58 ` Wen Yang
  0 siblings, 0 replies; 14+ messages in thread
From: Wen Yang @ 2019-04-08  2:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Neil Armstrong, David Airlie, Kevin Hilman, dri-devel,
	Markus Elfring, Daniel Vetter, linux-amlogic, Wen Yang,
	linux-arm-kernel

The call to of_graph_get_remote_port returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/gpu/drm/meson/meson_dw_hdmi.c:725:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 722, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: Markus Elfring <Markus.Elfring@web.de>
---
v2->v1: convert a if statement into a ternary statement.

 drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index 563953e..826b98b 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
 
 	/* If the endpoint node exists, consider it enabled */
 	remote = of_graph_get_remote_port(ep);
-	if (remote) {
-		of_node_put(ep);
-		return true;
-	}
-
 	of_node_put(ep);
 	of_node_put(remote);
 
-	return false;
+	return remote ? true : false;
 }
 
 static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
-- 
2.9.5

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

* [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08  2:58 ` Wen Yang
  0 siblings, 0 replies; 14+ messages in thread
From: Wen Yang @ 2019-04-08  2:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Neil Armstrong, David Airlie, Kevin Hilman, dri-devel,
	Markus Elfring, Daniel Vetter, linux-amlogic, Wen Yang,
	linux-arm-kernel

The call to of_graph_get_remote_port returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/gpu/drm/meson/meson_dw_hdmi.c:725:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 722, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: Markus Elfring <Markus.Elfring@web.de>
---
v2->v1: convert a if statement into a ternary statement.

 drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index 563953e..826b98b 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
 
 	/* If the endpoint node exists, consider it enabled */
 	remote = of_graph_get_remote_port(ep);
-	if (remote) {
-		of_node_put(ep);
-		return true;
-	}
-
 	of_node_put(ep);
 	of_node_put(remote);
 
-	return false;
+	return remote ? true : false;
 }
 
 static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
-- 
2.9.5


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

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

* [PATCH v2] drm/omap: fix possible object reference leak
  2019-04-08  2:58 ` Wen Yang
                   ` (2 preceding siblings ...)
  (?)
@ 2019-04-08  2:58 ` Wen Yang
  2019-04-08  8:49   ` Mukesh Ojha
  -1 siblings, 1 reply; 14+ messages in thread
From: Wen Yang @ 2019-04-08  2:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Wen Yang, Tomi Valkeinen, David Airlie, Daniel Vetter,
	Sebastian Reichel, Laurent Pinchart, dri-devel, Markus Elfring

The call to of_find_matching_node returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:212:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:237:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Cc: Markus Elfring <Markus.Elfring@web.de>
---
v2->v1: add a jump target.

 drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
index 2b41c75..13b3b4a 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
@@ -209,7 +209,7 @@ static int __init omapdss_boot_init(void)
 	dss = of_find_matching_node(NULL, omapdss_of_match);
 
 	if (dss == NULL || !of_device_is_available(dss))
-		return 0;
+		goto put_node;
 
 	omapdss_walk_device(dss, true);
 
@@ -234,6 +234,8 @@ static int __init omapdss_boot_init(void)
 		kfree(n);
 	}
 
+put_node:
+	of_node_put(dss);
 	return 0;
 }
 
-- 
2.9.5


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

* [PATCH v2] drm: rcar-du: fix possible object reference leak
  2019-04-08  2:58 ` Wen Yang
                   ` (3 preceding siblings ...)
  (?)
@ 2019-04-08  2:58 ` Wen Yang
  2019-04-08  8:45   ` Mukesh Ojha
  2019-04-08 16:38   ` Markus Elfring
  -1 siblings, 2 replies; 14+ messages in thread
From: Wen Yang @ 2019-04-08  2:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Wen Yang, Laurent Pinchart, Kieran Bingham,
	David Airlie, Daniel Vetter, dri-devel, linux-renesas-soc

The call to of_get_parent returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/gpu/drm/rcar-du/rcar_du_of.c:235:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 216, but without a corresponding object release within this function.
drivers/gpu/drm/rcar-du/rcar_du_of.c:236:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org (open list)
---
v2->v1: turn the return into a goto done.

 drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c b/drivers/gpu/drm/rcar-du/rcar_du_of.c
index afef696..782bfc7 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_of.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
@@ -232,7 +232,7 @@ static void __init rcar_du_of_lvds_patch(const struct of_device_id *of_ids)
 	lvds_node = of_find_compatible_node(NULL, NULL, compatible);
 	if (lvds_node) {
 		of_node_put(lvds_node);
-		return;
+		goto done;
 	}
 
 	/*
-- 
2.9.5


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

* Re: [PATCH v2] drm: rcar-du: fix possible object reference leak
  2019-04-08  2:58 ` [PATCH v2] drm: rcar-du: " Wen Yang
@ 2019-04-08  8:45   ` Mukesh Ojha
  2019-04-08  9:23     ` wen.yang99
  2019-04-08 16:38   ` Markus Elfring
  1 sibling, 1 reply; 14+ messages in thread
From: Mukesh Ojha @ 2019-04-08  8:45 UTC (permalink / raw)
  To: Wen Yang, linux-kernel
  Cc: wang.yi59, Laurent Pinchart, Kieran Bingham, David Airlie,
	Daniel Vetter, dri-devel, linux-renesas-soc


On 4/8/2019 8:28 AM, Wen Yang wrote:
> The call to of_get_parent returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> drivers/gpu/drm/rcar-du/rcar_du_of.c:235:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 216, but without a corresponding object release within this function.
> drivers/gpu/drm/rcar-du/rcar_du_of.c:236:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-renesas-soc@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org (open list)
> ---
> v2->v1: turn the return into a goto done.
>
>   drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> index afef696..782bfc7 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_of.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> @@ -232,7 +232,7 @@ static void __init rcar_du_of_lvds_patch(const struct of_device_id *of_ids)
>   	lvds_node = of_find_compatible_node(NULL, NULL, compatible);
>   	if (lvds_node) {
>   		of_node_put(lvds_node);
> -		return;
> +		goto done;
>   	}
>   


you might have to create multiple level to do handling it.. there are 
unnecessary put being done on "done" which is not valid

for this case.

-Mukesh

>   	/*

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

* Re: [PATCH v2] drm/omap: fix possible object reference leak
  2019-04-08  2:58 ` [PATCH v2] drm/omap: " Wen Yang
@ 2019-04-08  8:49   ` Mukesh Ojha
  0 siblings, 0 replies; 14+ messages in thread
From: Mukesh Ojha @ 2019-04-08  8:49 UTC (permalink / raw)
  To: Wen Yang, linux-kernel
  Cc: wang.yi59, Tomi Valkeinen, David Airlie, Daniel Vetter,
	Sebastian Reichel, Laurent Pinchart, dri-devel, Markus Elfring


On 4/8/2019 8:28 AM, Wen Yang wrote:
> The call to of_find_matching_node returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:212:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.
> drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:237:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

Cheers,
-Mukesh

> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Cc: Markus Elfring <Markus.Elfring@web.de>
> ---
> v2->v1: add a jump target.
>
>   drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> index 2b41c75..13b3b4a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> @@ -209,7 +209,7 @@ static int __init omapdss_boot_init(void)
>   	dss = of_find_matching_node(NULL, omapdss_of_match);
>   
>   	if (dss == NULL || !of_device_is_available(dss))
> -		return 0;
> +		goto put_node;
>   
>   	omapdss_walk_device(dss, true);
>   
> @@ -234,6 +234,8 @@ static int __init omapdss_boot_init(void)
>   		kfree(n);
>   	}
>   
> +put_node:
> +	of_node_put(dss);
>   	return 0;
>   }
>   

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

* Re: [PATCH v2] drm/meson: fix possible object reference leak
  2019-04-08  2:58 ` Wen Yang
  (?)
@ 2019-04-08  9:13   ` Markus Elfring
  -1 siblings, 0 replies; 14+ messages in thread
From: Markus Elfring @ 2019-04-08  9:13 UTC (permalink / raw)
  To: Wen Yang, dri-devel, linux-amlogic, linux-arm-kernel
  Cc: linux-kernel, Daniel Vetter, David Airlie, Kevin Hilman,
	Neil Armstrong, Yi Wang

> v2->v1: convert a if statement into a ternary statement.

Would you like to omit the arrow in such version information?


> @@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
>
>  	/* If the endpoint node exists, consider it enabled */
>  	remote = of_graph_get_remote_port(ep);
> -	if (remote) {
> -		of_node_put(ep);
> -		return true;
> -	}
> -
>  	of_node_put(ep);
>  	of_node_put(remote);

Can a reordering of the passed variables be useful for such function calls?

+  	of_node_put(remote);
+  	of_node_put(ep);

Regards,
Markus

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

* Re: [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08  9:13   ` Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Elfring @ 2019-04-08  9:13 UTC (permalink / raw)
  To: Wen Yang, dri-devel, linux-amlogic, linux-arm-kernel
  Cc: Yi Wang, Neil Armstrong, David Airlie, Kevin Hilman,
	linux-kernel, Daniel Vetter

> v2->v1: convert a if statement into a ternary statement.

Would you like to omit the arrow in such version information?


> @@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
>
>  	/* If the endpoint node exists, consider it enabled */
>  	remote = of_graph_get_remote_port(ep);
> -	if (remote) {
> -		of_node_put(ep);
> -		return true;
> -	}
> -
>  	of_node_put(ep);
>  	of_node_put(remote);

Can a reordering of the passed variables be useful for such function calls?

+  	of_node_put(remote);
+  	of_node_put(ep);

Regards,
Markus

_______________________________________________
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] 14+ messages in thread

* Re: [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08  9:13   ` Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Elfring @ 2019-04-08  9:13 UTC (permalink / raw)
  To: Wen Yang, dri-devel, linux-amlogic, linux-arm-kernel
  Cc: Yi Wang, Neil Armstrong, David Airlie, Kevin Hilman,
	linux-kernel, Daniel Vetter

> v2->v1: convert a if statement into a ternary statement.

Would you like to omit the arrow in such version information?


> @@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
>
>  	/* If the endpoint node exists, consider it enabled */
>  	remote = of_graph_get_remote_port(ep);
> -	if (remote) {
> -		of_node_put(ep);
> -		return true;
> -	}
> -
>  	of_node_put(ep);
>  	of_node_put(remote);

Can a reordering of the passed variables be useful for such function calls?

+  	of_node_put(remote);
+  	of_node_put(ep);

Regards,
Markus

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

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

* Re: [PATCH v2] drm: rcar-du: fix possible object reference leak
  2019-04-08  8:45   ` Mukesh Ojha
@ 2019-04-08  9:23     ` wen.yang99
  0 siblings, 0 replies; 14+ messages in thread
From: wen.yang99 @ 2019-04-08  9:23 UTC (permalink / raw)
  To: mojha
  Cc: wang.yi59, airlied, linux-kernel, dri-devel, linux-renesas-soc,
	kieran.bingham+renesas, laurent.pinchart


[-- Attachment #1.1: Type: text/plain, Size: 2457 bytes --]

> > The call to of_get_parent returns a node pointer with refcount
> > incremented thus it must be explicitly decremented after the last
> > usage.
> >
> > Detected by coccinelle with the following warnings:
> > drivers/gpu/drm/rcar-du/rcar_du_of.c:235:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 216, but without a corresponding object release within this function.
> > drivers/gpu/drm/rcar-du/rcar_du_of.c:236:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.
> >
> > Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> > Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: linux-renesas-soc@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org (open list)
> > ---
> > v2->v1: turn the return into a goto done.
> >
> >   drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> > index afef696..782bfc7 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_of.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> > @@ -232,7 +232,7 @@ static void __init rcar_du_of_lvds_patch(const struct of_device_id *of_ids)
> >       lvds_node = of_find_compatible_node(NULL, NULL, compatible);
> >       if (lvds_node) {
> >           of_node_put(lvds_node);
> > -        return;
> > +        goto done;
> >       }
> >
> 
> 
> you might have to create multiple level to do handling it.. there are
> unnecessary put being done on "done" which is not valid
> 
> for this case.

Hi Mukesh,
Thank you for your comments.
lvds_data has been initialized to 0, 
so the put operation in the done tag may have no effect:

199         struct lvds_of_data lvds_data[2] = { };
...
309 done:
310         for (i = 0; i < info->num_lvds; ++i) {
311                 of_node_put(lvds_data[i].clkspec.np);
312                 of_node_put(lvds_data[i].local);
313                 of_node_put(lvds_data[i].remote);
314         }
315 
316         of_node_put(soc_node);
317         of_node_put(du_node);

---
Thanks and regards,
Wen

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v2] drm/meson: fix possible object reference leak
  2019-04-08  9:13   ` Markus Elfring
  (?)
  (?)
@ 2019-04-08 10:25   ` wen.yang99
  -1 siblings, 0 replies; 14+ messages in thread
From: wen.yang99 @ 2019-04-08 10:25 UTC (permalink / raw)
  To: Markus.Elfring
  Cc: wang.yi59, narmstrong, airlied, khilman, linux-kernel, dri-devel,
	linux-amlogic, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1149 bytes --]

> > v2->v1: convert a if statement into a ternary statement.
> 
> Would you like to omit the arrow in such version information?

Thank you for your comments
The information about the previous versions goes below the ---, 
and only the reviewers can see it.
It does not appear in the git log log.
Thanks.

> > @@ -720,15 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
> >
> >      /* If the endpoint node exists, consider it enabled */
> >      remote = of_graph_get_remote_port(ep);
> > -    if (remote) {
> > -        of_node_put(ep);
> > -        return true;
> > -    }
> > -
> >      of_node_put(ep);
> >      of_node_put(remote);
> 
> Can a reordering of the passed variables be useful for such function calls?
> 
> +      of_node_put(remote);
> +      of_node_put(ep);
> 

Thank you.
But considering the multiprocessor concurrent execution, 
the reverse of the order of these two statements may not have additional benefits.
The previous code implementation also maintains this order, 
and we will keep the original order unless we can prove that the reverse order can indeed bring real benefits.

--
Regards,
Wen

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v2] drm: rcar-du: fix possible object reference leak
  2019-04-08  2:58 ` [PATCH v2] drm: rcar-du: " Wen Yang
  2019-04-08  8:45   ` Mukesh Ojha
@ 2019-04-08 16:38   ` Markus Elfring
  1 sibling, 0 replies; 14+ messages in thread
From: Markus Elfring @ 2019-04-08 16:38 UTC (permalink / raw)
  To: Wen Yang, Laurent Pinchart, dri-devel, linux-renesas-soc
  Cc: linux-kernel, Daniel Vetter, David Airlie, Kieran Bingham,
	Mukesh Ojha, Yi Wang

> v2->v1: turn the return into a goto done.

* The version identification can be shorter, can't it?

* The expection handling should be completed for the implementation
  of the function “rcar_du_of_lvds_patch” in a different way.
  https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/rcar-du/rcar_du_of.c?id=ac5b84a1ffe93c9fb882c0f2bdfac1c33077b920#n195

  How do you think about to add a few jump targets (at the end)?

Regards,
Markus

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

end of thread, other threads:[~2019-04-08 16:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08  2:58 [PATCH v2] drm/meson: fix possible object reference leak Wen Yang
2019-04-08  2:58 ` Wen Yang
2019-04-08  2:58 ` Wen Yang
2019-04-08  2:58 ` Wen Yang
2019-04-08  2:58 ` [PATCH v2] drm/omap: " Wen Yang
2019-04-08  8:49   ` Mukesh Ojha
2019-04-08  2:58 ` [PATCH v2] drm: rcar-du: " Wen Yang
2019-04-08  8:45   ` Mukesh Ojha
2019-04-08  9:23     ` wen.yang99
2019-04-08 16:38   ` Markus Elfring
2019-04-08  9:13 ` [PATCH v2] drm/meson: " Markus Elfring
2019-04-08  9:13   ` Markus Elfring
2019-04-08  9:13   ` Markus Elfring
2019-04-08 10:25   ` wen.yang99

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.