# \[PATCH AUTOSEL 4.4 09/16\] drm/omap: fix possible object reference leak

- Subsystems: FRAMEBUFFER LAYER, OMAP DISPLAY SUBSYSTEM and FRAMEBUFFER SUPPORT (DSS2), THE REST
- Maintainers: Helge Deller, Linus Torvalds
- Status: REVIEWED · 2 reviews, 1 by a maintainer (M Laurent Pinchart Mukesh Ojha)
- Reviewed.
- 2 review trailers.
- List: linux-fbdev
- 1 message, 1 author
- Page: https://ratatoskr.run/linux-fbdev/2020/04/5924549/t

## \[PATCH AUTOSEL 4.4 09/16\] drm/omap: fix possible object reference leak

- From: Sasha Levin \<sashal@kernel.org\>
- Date: 2020-04-11 23:15:23 
- Message: https://ratatoskr.run/linux-fbdev/2020/04/5924549.md

```text
From: Wen Yang <redacted>

[ Upstream commit 47340e46f34a3b1d80e40b43ae3d7a8da34a3541 ]

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 <redacted>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Mukesh Ojha <redacted>
Cc: Tomi Valkeinen <redacted>
Cc: David Airlie <redacted>
Cc: Daniel Vetter <redacted>
Cc: Sebastian Reichel <redacted>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: <redacted>
Cc: <redacted>
Cc: Markus Elfring <redacted>
Signed-off-by: Tomi Valkeinen <redacted>
Link: https://patchwork.freedesktop.org/patch/msgid/1554692313-28882-2-git-send-email-wen.yang99@zte.com.cn
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/fbdev/omap2/dss/omapdss-boot-init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
index 8b6f6d5fdd68b..43186fa8a13c9 100644
--- a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
@@ -194,7 +194,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);
 
@@ -221,6 +221,8 @@ static int __init omapdss_boot_init(void)
 		kfree(n);
 	}
 
+put_node:
+	of_node_put(dss);
 	return 0;
 }
 
-- 
2.20.1
```
