Thread (21 messages) 21 messages, 5 authors, 2024-09-02

Re: [PATCH v3 1/9] of: property: add of_graph_get_next_port()

From: Krzysztof Kozlowski <krzk@kernel.org>
Date: 2024-08-26 05:57:54
Also in: dri-devel, linux-devicetree, linux-fbdev, linux-media, linux-omap, linux-sound

On Mon, Aug 26, 2024 at 02:43:23AM +0000, Kuninori Morimoto wrote:
We have endpoint base functions
	- of_graph_get_next_device_endpoint()
	- of_graph_get_device_endpoint_count()
	- for_each_of_graph_device_endpoint()
+	if (!prev) {
+		/*
+		 * Find "ports" node from parent
+		 *
+		 *	parent {
+		 * =>		ports {
+		 *			port {...};
+		 *		};
+		 *	};
+		 */
+		prev = of_get_child_by_name(parent, "ports");
+
+		/*
+		 * Use parent as its ports if it not exist
+		 *
+		 * =>	parent {
+		 *		port {...};
+		 *	};
+		 */
+		if (!prev) {
+			prev = of_node_get(parent);
+
+			/* check wether it has port node */
+			struct device_node *port __free(device_node) =
+				of_get_child_by_name(prev, "port");
+
+			if (!port)
+				prev = NULL;
It looks like you leak here "prev".
+		}
+
+		return prev;
+	}
Best regards,
Krzysztof

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help