diff mbox series

drm: of: fix a potential double put bug

Message ID 20220419121408.1291270-1-william.xuanziyang@huawei.com (mailing list archive)
State New, archived
Headers show
Series drm: of: fix a potential double put bug | expand

Commit Message

Ziyang Xuan (William) April 19, 2022, 12:14 p.m. UTC
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(-)

Comments

Ziyang Xuan (William) April 29, 2022, 9:44 a.m. UTC | #1
Is there any comments about the path?

Thank you.
diff mbox series

Patch

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;