linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: of: fix a potential double put bug
@ 2022-04-19 12:14 Ziyang Xuan
  0 siblings, 0 replies; only message in thread
From: Ziyang Xuan @ 2022-04-19 12:14 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, daniel,
	dri-devel, linux-kernel

Execute the following coccinelle rule:
$make coccicheck COCCI=scripts/coccinelle/iterators/device_node_continue.cocci

Get an error report as following:
./drivers/gpu/drm/drm_of.c:292:2-13: ERROR: probable double put.

Device node iterators put the previous value of the index variable,
when find_panel_or_bridge() return non-zero, it will causes a double put.

Fixes: 67bae5f28c89 ("drm: of: Properly try all possible cases for bridge/panel detection")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 drivers/gpu/drm/drm_of.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index f4df344509a8..8c3c0bca1af1 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -289,11 +289,12 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
 			continue;
 
 		ret = find_panel_or_bridge(node, panel, bridge);
-		of_node_put(node);
 
 		/* Stop at the first found occurrence. */
-		if (!ret)
+		if (!ret) {
+			of_node_put(node);
 			return 0;
+		}
 	}
 
 	return -EPROBE_DEFER;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-19 11:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 12:14 [PATCH] drm: of: fix a potential double put bug Ziyang Xuan

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