* [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08 2:58 Wen Yang
2019-04-08 2:58 ` [PATCH v2] drm/omap: " Wen Yang
` (2 more replies)
0 siblings, 3 replies; 7+ 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] 7+ messages in thread
* [PATCH v2] drm/omap: fix possible object reference leak
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 8:49 ` Mukesh Ojha
2019-04-08 2:58 ` [PATCH v2] drm: rcar-du: " Wen Yang
2019-04-08 9:13 ` [PATCH v2] drm/meson: " Markus Elfring
2 siblings, 1 reply; 7+ 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] 7+ messages in thread
* [PATCH v2] drm: rcar-du: fix possible object reference leak
2019-04-08 2:58 [PATCH v2] drm/meson: fix possible object reference leak Wen Yang
2019-04-08 2:58 ` [PATCH v2] drm/omap: " Wen Yang
@ 2019-04-08 2:58 ` Wen Yang
2019-04-08 8:45 ` Mukesh Ojha
2019-04-08 16:38 ` Markus Elfring
2019-04-08 9:13 ` [PATCH v2] drm/meson: " Markus Elfring
2 siblings, 2 replies; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ messages in thread
* Re: [PATCH v2] drm/meson: fix possible object reference leak
2019-04-08 2:58 [PATCH v2] drm/meson: fix possible object reference leak Wen Yang
2019-04-08 2:58 ` [PATCH v2] drm/omap: " Wen Yang
2019-04-08 2:58 ` [PATCH v2] drm: rcar-du: " Wen Yang
@ 2019-04-08 9:13 ` Markus Elfring
2 siblings, 0 replies; 7+ 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] 7+ 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; 7+ 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] 7+ messages in thread
end of thread, other threads:[~2019-04-08 16:39 UTC | newest]
Thread overview: 7+ 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 ` [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 16:38 ` Markus Elfring
2019-04-08 9:13 ` [PATCH v2] drm/meson: " Markus Elfring
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).