Thread (28 messages) 28 messages, 3 authors, 2020-03-11

Re: [PATCH v12 06/19] media: v4l2-fwnode: add initial connector parsing support

From: Sakari Ailus <sakari.ailus@linux.intel.com>
Date: 2020-03-11 09:03:39
Also in: linux-media

On Wed, Mar 11, 2020 at 09:43:57AM +0100, Marco Felsch wrote:
Hi Sakari,

On 20-03-11 10:17, Sakari Ailus wrote:
quoted
Hi Marco,

On Mon, Mar 09, 2020 at 11:14:15AM +0100, Marco Felsch wrote:
...
quoted
+void v4l2_fwnode_connector_free(struct v4l2_fwnode_connector *connector)
+{
+	struct v4l2_connector_link *link, *tmp;
+
+	if (IS_ERR_OR_NULL(connector) ||
+	    connector->type == V4L2_CONN_UNKNOWN)
+		return;
+
+	list_for_each_entry_safe(link, tmp, &connector->links, head) {
+		v4l2_fwnode_put_link(&link->fwnode_link);
+		list_del(&link->head);
+		kfree(link);
+	}
+
+	kfree(connector->label);
+	connector->label = NULL;
+	connector = NULL;
No need to set connector NULL here.
My intention was to make it safe e.g. if a caller calls this twice for
the same connector.
This changes the pointer to NULL locally but the caller won't see this ---
because it's the value of the pointer that was passed here by the caller.

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