Skip to contentSkip to conversation

media: ov5645: add missing of_node_put() in error path

PATCH In review Akinobu Mita 2 participants 2 messages Mar 19, 2018 – Mar 21, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: ov5645: add missing of_node_put() in error path

The device node obtained with of_graph_get_next_endpoint() should be released by calling of_node_put(). But it was not released when v4l2_fwnode_endpoint_parse() failed.

This change moves the of_node_put() call before the error check and fixes the issue.

Cc Todor Tomov <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ov5645.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/ov5645.c +3 -2
index d28845f..a31fe18 100644
@@ -1131,13 +1131,14 @@ static int ov5645_probe(struct i2c_client *client,
 
 	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint),
 					 &ov5645->ep);
+
+	of_node_put(endpoint);
+
 	if (ret < 0) {
 		dev_err(dev, "parsing endpoint node failed\n");
 		return ret;
 	}
 
-	of_node_put(endpoint);
-
 	if (ov5645->ep.bus_type != V4L2_MBUS_CSI2) {
 		dev_err(dev, "invalid bus type, must be CSI2\n");
 		return -EINVAL;
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw

Thank you Akinobu.

Quoted 37 lines · Akinobu Mita

The device node obtained with of_graph_get_next_endpoint() should be released by calling of_node_put(). But it was not released when v4l2_fwnode_endpoint_parse() failed.

This change moves the of_node_put() call before the error check and fixes the issue.

Cc Todor Tomov <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ov5645.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/ov5645.c +3 -2
index d28845f..a31fe18 100644
@@ -1131,13 +1131,14 @@ static int ov5645_probe(struct i2c_client *client,
 
 	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint),
 					 &ov5645->ep);
+
+	of_node_put(endpoint);
+
 	if (ret < 0) {
 		dev_err(dev, "parsing endpoint node failed\n");
 		return ret;
 	}
 
-	of_node_put(endpoint);
-
 	if (ov5645->ep.bus_type != V4L2_MBUS_CSI2) {
 		dev_err(dev, "invalid bus type, must be CSI2\n");
 		return -EINVAL;