mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm: of: fix leak of endpoint
@ 2020-09-25 22:44 Tobias Jordan
  0 siblings, 0 replies; only message in thread
From: Tobias Jordan @ 2020-09-25 22:44 UTC (permalink / raw)
  To: dri-devel, linux-kernel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Laurent Pinchart, Fabrizio Castro

The for_each_child_of_node loop in drm_of_lvds_get_remote_pixels_type
bails out in two occasions. Originally, both were calling of_node_put to
clean up, but (probably a typo) for the wrong variable.

One of these typos was fixed in commit 4ee48cc5586b ("drm: of: Fix
double-free bug"), but that missed the leak of the original endpoint
and also the first error path which was obviously wrong as well.

Fix the leak of endpoint in the error path by calling of_node_put on
it.

Fixes: 6529007522de ("drm: of: Add drm_of_lvds_get_dual_link_pixel_order")
Signed-off-by: Tobias Jordan <kernel@cdqe.de>
---
Sorry for the confusion, it seems it's not that easy to get the variable
name right. Please disregard the patch sent a few minutes ago, this is
the right one.

 drivers/gpu/drm/drm_of.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index ca04c34e8251..997b8827fed2 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -315,7 +315,7 @@ static int drm_of_lvds_get_remote_pixels_type(
 
 		remote_port = of_graph_get_remote_port(endpoint);
 		if (!remote_port) {
-			of_node_put(remote_port);
+			of_node_put(endpoint);
 			return -EPIPE;
 		}
 
@@ -331,8 +331,10 @@ static int drm_of_lvds_get_remote_pixels_type(
 		 * configurations by passing the endpoints explicitly to
 		 * drm_of_lvds_get_dual_link_pixel_order().
 		 */
-		if (!current_pt || pixels_type != current_pt)
+		if (!current_pt || pixels_type != current_pt) {
+			of_node_put(endpoint);
 			return -EINVAL;
+		}
 	}
 
 	return pixels_type;
-- 
2.20.1


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

only message in thread, other threads:[~2020-09-25 22:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25 22:44 [PATCH] drm: of: fix leak of endpoint Tobias Jordan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®