* [PATCH 0/7] fix possible object reference leaks in drivers/gpu
@ 2019-04-03 16:04 Wen Yang
2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang
` (6 more replies)
0 siblings, 7 replies; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw)
To: linux-kernel; +Cc: wang.yi59, Wen Yang
The call to of_get_cpu_node/of_find_compatible_node/of_parse_phandle...
returns a node pointer with refcount incremented thus it must be
explicitly decremented after the last usage.
This patch series fix those possible object reference leaks in drivers/gpu.
Wen Yang (7):
drm/mediatek: fix possible object reference leak
drm/meson: fix possible object reference leak
drm/msm: a5xx: fix possible object reference leak
drm/omap: fix possible object reference leak
drm/pl111: fix possible object reference leak
drm: rcar-du: fix possible object reference leak
drm/tegra: fix possible object reference leak
drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 +
drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 ++-----
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 10 ++++++----
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 5 ++++-
drivers/gpu/drm/pl111/pl111_versatile.c | 4 ++++
drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 ++
drivers/gpu/drm/tegra/output.c | 2 ++
drivers/gpu/drm/tegra/rgb.c | 8 ++++++--
8 files changed, 27 insertions(+), 12 deletions(-)
--
2.9.5
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/7] drm/mediatek: fix possible object reference leak
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
@ 2019-04-03 16:04 ` Wen Yang
2019-04-09 5:15 ` CK Hu
2019-04-03 16:04 ` [PATCH 2/7] drm/meson: " Wen Yang
` (5 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Wen Yang, CK Hu, Philipp Zabel, David Airlie,
Daniel Vetter, Matthias Brugger, dri-devel, linux-arm-kernel,
linux-mediatek
The call to of_parse_phandle 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/mediatek/mtk_hdmi.c:1521:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function.
drivers/gpu/drm/mediatek/mtk_hdmi.c:1524:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 915cc84..ed10f4d 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1516,6 +1516,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
of_node_put(remote);
hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
+ of_node_put(i2c_np);
if (!hdmi->ddc_adpt) {
dev_err(dev, "Failed to get ddc i2c adapter by node\n");
return -EINVAL;
--
2.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/7] drm/meson: fix possible object reference leak
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang
@ 2019-04-03 16:04 ` Wen Yang
2019-04-04 20:05 ` Markus Elfring
2019-04-03 16:04 ` [PATCH 3/7] drm/msm: a5xx: " Wen Yang
` (4 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 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
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 (open list)
---
drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index 563953e..109a933 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -720,13 +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);
+ if (remote)
+ return true;
return false;
}
--
2.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/7] drm/msm: a5xx: fix possible object reference leak
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang
2019-04-03 16:04 ` [PATCH 2/7] drm/meson: " Wen Yang
@ 2019-04-03 16:04 ` Wen Yang
2019-04-10 16:21 ` Jordan Crouse
2019-04-03 16:04 ` [PATCH 4/7] drm/omap: " Wen Yang
` (3 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Wen Yang, Rob Clark, Sean Paul, David Airlie,
Daniel Vetter, Jordan Crouse, Mamta Shukla, Thomas Zimmermann,
Sharat Masetty, linux-arm-msm, dri-devel, freedreno
The call to of_get_child_by_name 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/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
drivers/gpu/drm/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jordan Crouse <jcrouse@codeaurora.org>
Cc: Mamta Shukla <mamtashukla555@gmail.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Sharat Masetty <smasetty@codeaurora.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: freedreno@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org (open list)
---
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index d5f5e56..270da14 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -34,7 +34,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname)
{
struct device *dev = &gpu->pdev->dev;
const struct firmware *fw;
- struct device_node *np;
+ struct device_node *np, *mem_np;
struct resource r;
phys_addr_t mem_phys;
ssize_t mem_size;
@@ -48,11 +48,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname)
if (!np)
return -ENODEV;
- np = of_parse_phandle(np, "memory-region", 0);
- if (!np)
+ mem_np = of_parse_phandle(np, "memory-region", 0);
+ of_node_put(np);
+ if (!mem_np)
return -EINVAL;
- ret = of_address_to_resource(np, 0, &r);
+ ret = of_address_to_resource(mem_np, 0, &r);
+ of_node_put(mem_np);
if (ret)
return ret;
--
2.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/7] drm/omap: fix possible object reference leak
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
` (2 preceding siblings ...)
2019-04-03 16:04 ` [PATCH 3/7] drm/msm: a5xx: " Wen Yang
@ 2019-04-03 16:04 ` Wen Yang
2019-04-04 13:25 ` Laurent Pinchart
2019-04-04 20:42 ` Markus Elfring
2019-04-03 16:04 ` [PATCH 5/7] drm/pl111: " Wen Yang
` (2 subsequent siblings)
6 siblings, 2 replies; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Wen Yang, Tomi Valkeinen, David Airlie, Daniel Vetter,
Sebastian Reichel, Laurent Pinchart, dri-devel
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>
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
---
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 5 ++++-
1 file changed, 4 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..60067e8 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
@@ -208,8 +208,10 @@ static int __init omapdss_boot_init(void)
dss = of_find_matching_node(NULL, omapdss_of_match);
- if (dss == NULL || !of_device_is_available(dss))
+ if (dss == NULL || !of_device_is_available(dss)) {
+ of_node_put(dss);
return 0;
+ }
omapdss_walk_device(dss, true);
@@ -234,6 +236,7 @@ static int __init omapdss_boot_init(void)
kfree(n);
}
+ of_node_put(dss);
return 0;
}
--
2.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/7] drm/pl111: fix possible object reference leak
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
` (3 preceding siblings ...)
2019-04-03 16:04 ` [PATCH 4/7] drm/omap: " Wen Yang
@ 2019-04-03 16:04 ` Wen Yang
2019-04-04 19:59 ` Eric Anholt
2019-04-04 21:05 ` Markus Elfring
2019-04-03 16:04 ` [PATCH 6/7] drm: rcar-du: " Wen Yang
2019-04-03 16:04 ` [PATCH 7/7] drm/tegra: " Wen Yang
6 siblings, 2 replies; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Wen Yang, Eric Anholt, David Airlie, Daniel Vetter,
open list:DRM DRIVERS
The call to of_find_matching_node_and_match 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/pl111/pl111_versatile.c:333:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:340:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:346:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:354:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:395:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:402:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Eric Anholt <eric@anholt.net> (supporter:DRM DRIVER FOR ARM PL111 CLCD)
Cc: David Airlie <airlied@linux.ie> (maintainer:DRM DRIVERS)
Cc: Daniel Vetter <daniel@ffwll.ch> (maintainer:DRM DRIVERS)
Cc: dri-devel@lists.freedesktop.org (open list:DRM DRIVERS)
Cc: linux-kernel@vger.kernel.org (open list)
---
drivers/gpu/drm/pl111/pl111_versatile.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/pl111/pl111_versatile.c b/drivers/gpu/drm/pl111/pl111_versatile.c
index b9baefd..1c318ad 100644
--- a/drivers/gpu/drm/pl111/pl111_versatile.c
+++ b/drivers/gpu/drm/pl111/pl111_versatile.c
@@ -330,6 +330,7 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
ret = vexpress_muxfpga_init();
if (ret) {
dev_err(dev, "unable to initialize muxfpga driver\n");
+ of_node_put(np);
return ret;
}
@@ -337,17 +338,20 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
pdev = of_find_device_by_node(np);
if (!pdev) {
dev_err(dev, "can't find the sysreg device, deferring\n");
+ of_node_put(np);
return -EPROBE_DEFER;
}
map = dev_get_drvdata(&pdev->dev);
if (!map) {
dev_err(dev, "sysreg has not yet probed\n");
platform_device_put(pdev);
+ of_node_put(np);
return -EPROBE_DEFER;
}
} else {
map = syscon_node_to_regmap(np);
}
+ of_node_put(np);
if (IS_ERR(map)) {
dev_err(dev, "no Versatile syscon regmap\n");
--
2.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 6/7] drm: rcar-du: fix possible object reference leak
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
` (4 preceding siblings ...)
2019-04-03 16:04 ` [PATCH 5/7] drm/pl111: " Wen Yang
@ 2019-04-03 16:04 ` Wen Yang
2019-04-04 13:35 ` Laurent Pinchart
2019-04-03 16:04 ` [PATCH 7/7] drm/tegra: " Wen Yang
6 siblings, 1 reply; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 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>
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)
---
drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c b/drivers/gpu/drm/rcar-du/rcar_du_of.c
index afef696..30bceca 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_of.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
@@ -232,6 +232,8 @@ 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);
+ of_node_put(soc_node);
+ of_node_put(du_node);
return;
}
--
2.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 7/7] drm/tegra: fix possible object reference leak
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
` (5 preceding siblings ...)
2019-04-03 16:04 ` [PATCH 6/7] drm: rcar-du: " Wen Yang
@ 2019-04-03 16:04 ` Wen Yang
6 siblings, 0 replies; 16+ messages in thread
From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Wen Yang, Thierry Reding, David Airlie, Daniel Vetter,
Jonathan Hunter, dri-devel, linux-tegra
The call to of_get_child_by_name 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/tegra/rgb.c:225:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 223, but without a corresponding object release within this function.
./drivers/gpu/drm/tegra/rgb.c:229:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 223, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-tegra@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/gpu/drm/tegra/output.c | 2 ++
drivers/gpu/drm/tegra/rgb.c | 8 ++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 9c2b9da..78553d7 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -193,6 +193,8 @@ void tegra_output_remove(struct tegra_output *output)
if (output->ddc)
put_device(&output->ddc->dev);
+ if (output->of_node)
+ of_node_put(output->of_node);
}
int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index 28a78d3..ad683a2 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -221,12 +221,16 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
int err;
np = of_get_child_by_name(dc->dev->of_node, "rgb");
- if (!np || !of_device_is_available(np))
+ if (!np || !of_device_is_available(np)) {
+ of_node_put(np);
return -ENODEV;
+ }
rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL);
- if (!rgb)
+ if (!rgb) {
+ of_node_put(np);
return -ENOMEM;
+ }
rgb->output.dev = dc->dev;
rgb->output.of_node = np;
--
2.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] drm/omap: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 4/7] drm/omap: " Wen Yang
@ 2019-04-04 13:25 ` Laurent Pinchart
2019-04-04 20:42 ` Markus Elfring
1 sibling, 0 replies; 16+ messages in thread
From: Laurent Pinchart @ 2019-04-04 13:25 UTC (permalink / raw)
To: Wen Yang
Cc: linux-kernel, wang.yi59, Tomi Valkeinen, David Airlie,
Daniel Vetter, Sebastian Reichel, dri-devel
Hello Wen,
Thank you for the patch.
On Thu, Apr 04, 2019 at 12:04:12AM +0800, 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>
> 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
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Would you like to get the series merged in one go, or individual patches
picked by the respective maintainer ?
> ---
> drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 5 ++++-
> 1 file changed, 4 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..60067e8 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> @@ -208,8 +208,10 @@ static int __init omapdss_boot_init(void)
>
> dss = of_find_matching_node(NULL, omapdss_of_match);
>
> - if (dss == NULL || !of_device_is_available(dss))
> + if (dss == NULL || !of_device_is_available(dss)) {
> + of_node_put(dss);
> return 0;
> + }
>
> omapdss_walk_device(dss, true);
>
> @@ -234,6 +236,7 @@ static int __init omapdss_boot_init(void)
> kfree(n);
> }
>
> + of_node_put(dss);
> return 0;
> }
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/7] drm: rcar-du: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 6/7] drm: rcar-du: " Wen Yang
@ 2019-04-04 13:35 ` Laurent Pinchart
0 siblings, 0 replies; 16+ messages in thread
From: Laurent Pinchart @ 2019-04-04 13:35 UTC (permalink / raw)
To: Wen Yang
Cc: linux-kernel, wang.yi59, Kieran Bingham, David Airlie,
Daniel Vetter, dri-devel, linux-renesas-soc
Hi Wen,
Thank you for the patch.
On Thu, Apr 04, 2019 at 12:04:14AM +0800, 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>
> 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)
> ---
> drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> index afef696..30bceca 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_of.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> @@ -232,6 +232,8 @@ 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);
> + of_node_put(soc_node);
> + of_node_put(du_node);
> return;
Wouldn't it be simpler to just turn the return into a goto done ?
> }
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/7] drm/pl111: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 5/7] drm/pl111: " Wen Yang
@ 2019-04-04 19:59 ` Eric Anholt
2019-04-04 21:05 ` Markus Elfring
1 sibling, 0 replies; 16+ messages in thread
From: Eric Anholt @ 2019-04-04 19:59 UTC (permalink / raw)
To: Wen Yang, linux-kernel
Cc: wang.yi59, Wen Yang, David Airlie, Daniel Vetter, open list:DRM DRIVERS
[-- Attachment #1: Type: text/plain, Size: 237 bytes --]
Wen Yang <wen.yang99@zte.com.cn> writes:
> The call to of_find_matching_node_and_match returns a node pointer with
> refcount incremented thus it must be explicitly decremented after the
> last usage.
Pushed to drm-misc-next. Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] drm/meson: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 2/7] drm/meson: " Wen Yang
@ 2019-04-04 20:05 ` Markus Elfring
0 siblings, 0 replies; 16+ messages in thread
From: Markus Elfring @ 2019-04-04 20:05 UTC (permalink / raw)
To: Wen Yang, dri-devel, kernel-janitors
Cc: linux-amlogic, linux-arm-kernel, linux-kernel, Daniel Vetter,
David Airlie, Kevin Hilman, Neil Armstrong, Yi Wang
> @@ -720,13 +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);
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/meson/meson_dw_hdmi.c?id=61de49cb596710b918f7a80839f0b6de2017bc32#n712
Can the order of these put calls matter (because of processor caches)?
> + if (remote)
> + return true;
>
> return false;
Would the use of a ternary operator be more succinct here?
+ return remote ? true : false;
Regards,
Markus
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] drm/omap: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 4/7] drm/omap: " Wen Yang
2019-04-04 13:25 ` Laurent Pinchart
@ 2019-04-04 20:42 ` Markus Elfring
1 sibling, 0 replies; 16+ messages in thread
From: Markus Elfring @ 2019-04-04 20:42 UTC (permalink / raw)
To: Wen Yang, dri-devel, kernel-janitors
Cc: linux-kernel, Daniel Vetter, David Airlie, Laurent Pinchart,
Sebastian Reichel, Tomi Valkeinen, Yi Wang
> @@ -208,8 +208,10 @@ static int __init omapdss_boot_init(void)
>
> dss = of_find_matching_node(NULL, omapdss_of_match);
>
> - if (dss == NULL || !of_device_is_available(dss))
> + if (dss == NULL || !of_device_is_available(dss)) {
> + of_node_put(dss);
> return 0;
> + }
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c?id=61de49cb596710b918f7a80839f0b6de2017bc32#n203
Can it be nicer to add a jump target here?
+ if (!dss || !of_device_is_available(dss))
- return 0;
+ goto put_node;
>
> omapdss_walk_device(dss, true);
>
> @@ -234,6 +236,7 @@ static int __init omapdss_boot_init(void)
> kfree(n);
> }
>
+put_node:
> + of_node_put(dss);
> return 0;
> }
Regards,
Markus
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/7] drm/pl111: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 5/7] drm/pl111: " Wen Yang
2019-04-04 19:59 ` Eric Anholt
@ 2019-04-04 21:05 ` Markus Elfring
1 sibling, 0 replies; 16+ messages in thread
From: Markus Elfring @ 2019-04-04 21:05 UTC (permalink / raw)
To: Wen Yang, Eric Anholt, dri-devel, kernel-janitors
Cc: linux-kernel, Daniel Vetter, David Airlie, Yi Wang
> @@ -337,17 +338,20 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
> pdev = of_find_device_by_node(np);
> if (!pdev) {
> dev_err(dev, "can't find the sysreg device, deferring\n");
> + of_node_put(np);
> return -EPROBE_DEFER;
> }
> map = dev_get_drvdata(&pdev->dev);
> if (!map) {
> dev_err(dev, "sysreg has not yet probed\n");
> platform_device_put(pdev);
> + of_node_put(np);
> return -EPROBE_DEFER;
> }
How do you think about to move duplicate statements to an additional
jump target for the desired exception handling?
Regards,
Markus
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] drm/mediatek: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang
@ 2019-04-09 5:15 ` CK Hu
0 siblings, 0 replies; 16+ messages in thread
From: CK Hu @ 2019-04-09 5:15 UTC (permalink / raw)
To: Wen Yang
Cc: linux-kernel, wang.yi59, Philipp Zabel, David Airlie,
Daniel Vetter, Matthias Brugger, dri-devel, linux-arm-kernel,
linux-mediatek
Hi, Wen:
On Thu, 2019-04-04 at 00:04 +0800, Wen Yang wrote:
> The call to of_parse_phandle 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/mediatek/mtk_hdmi.c:1521:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function.
> drivers/gpu/drm/mediatek/mtk_hdmi.c:1524:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function.
For this patch, applied to mediatek-drm-fixes-5.1 [1], thanks.
[1]
https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.1
Regards,
CK
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> index 915cc84..ed10f4d 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> @@ -1516,6 +1516,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
> of_node_put(remote);
>
> hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
> + of_node_put(i2c_np);
> if (!hdmi->ddc_adpt) {
> dev_err(dev, "Failed to get ddc i2c adapter by node\n");
> return -EINVAL;
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/7] drm/msm: a5xx: fix possible object reference leak
2019-04-03 16:04 ` [PATCH 3/7] drm/msm: a5xx: " Wen Yang
@ 2019-04-10 16:21 ` Jordan Crouse
0 siblings, 0 replies; 16+ messages in thread
From: Jordan Crouse @ 2019-04-10 16:21 UTC (permalink / raw)
To: Wen Yang
Cc: linux-kernel, wang.yi59, Rob Clark, Sean Paul, David Airlie,
Daniel Vetter, Mamta Shukla, Thomas Zimmermann, Sharat Masetty,
linux-arm-msm, dri-devel, freedreno
On Thu, Apr 04, 2019 at 12:04:11AM +0800, Wen Yang wrote:
> The call to of_get_child_by_name 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/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
> drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
> drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
> drivers/gpu/drm/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
> drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
> drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Jordan Crouse <jcrouse@codeaurora.org>
> Cc: Mamta Shukla <mamtashukla555@gmail.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Sharat Masetty <smasetty@codeaurora.org>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> Cc: freedreno@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org (open list)
Sorry for the delay. This looks right to me and possibly appropriate for stable
as well.
Reviewed-by: Jordan Crouse <jcrouse@codeaurora.org>
> ---
> drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> index d5f5e56..270da14 100644
> --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> @@ -34,7 +34,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname)
> {
> struct device *dev = &gpu->pdev->dev;
> const struct firmware *fw;
> - struct device_node *np;
> + struct device_node *np, *mem_np;
> struct resource r;
> phys_addr_t mem_phys;
> ssize_t mem_size;
> @@ -48,11 +48,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname)
> if (!np)
> return -ENODEV;
>
> - np = of_parse_phandle(np, "memory-region", 0);
> - if (!np)
> + mem_np = of_parse_phandle(np, "memory-region", 0);
> + of_node_put(np);
> + if (!mem_np)
> return -EINVAL;
>
> - ret = of_address_to_resource(np, 0, &r);
> + ret = of_address_to_resource(mem_np, 0, &r);
> + of_node_put(mem_np);
> if (ret)
> return ret;
>
> --
> 2.9.5
>
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2019-04-10 16:21 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 16:04 [PATCH 0/7] fix possible object reference leaks in drivers/gpu Wen Yang
2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang
2019-04-09 5:15 ` CK Hu
2019-04-03 16:04 ` [PATCH 2/7] drm/meson: " Wen Yang
2019-04-04 20:05 ` Markus Elfring
2019-04-03 16:04 ` [PATCH 3/7] drm/msm: a5xx: " Wen Yang
2019-04-10 16:21 ` Jordan Crouse
2019-04-03 16:04 ` [PATCH 4/7] drm/omap: " Wen Yang
2019-04-04 13:25 ` Laurent Pinchart
2019-04-04 20:42 ` Markus Elfring
2019-04-03 16:04 ` [PATCH 5/7] drm/pl111: " Wen Yang
2019-04-04 19:59 ` Eric Anholt
2019-04-04 21:05 ` Markus Elfring
2019-04-03 16:04 ` [PATCH 6/7] drm: rcar-du: " Wen Yang
2019-04-04 13:35 ` Laurent Pinchart
2019-04-03 16:04 ` [PATCH 7/7] drm/tegra: " Wen Yang
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).