diff mbox series

staging: vc04_services: Add error handling for vchiq_mmal_port_connect_tunnel

Message ID 20250121031921.2076-1-vulab@iscas.ac.cn (mailing list archive)
State New
Headers show
Series staging: vc04_services: Add error handling for vchiq_mmal_port_connect_tunnel | expand

Commit Message

Wentao Liang Jan. 21, 2025, 3:19 a.m. UTC
In mmal_setup_video_component() and mmal_setup_components(),
two vchiq_mmal_port_connect_tunnel() are called without proper
error handling. This could lead to unnoticed failures and
inconsistent behavior compared to other parts of the code.

In this patch, error handlings have been added for calls
to vchiq_mmal_port_connect_tunnel(), enhancing code robustness
and ensuring consistent error management.

Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index deec33f63bcf..eb9f484548ff 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -1021,6 +1021,8 @@  static int mmal_setup_video_component(struct bcm2835_mmal_dev *dev,
 			ret = vchiq_mmal_port_connect_tunnel(dev->instance,
 							     preview_port,
 							     NULL);
+			if (ret)
+				return ret;
 		}
 	}
 	preview_port->es.video.width = f->fmt.pix.width;
@@ -1153,8 +1155,10 @@  static int mmal_setup_components(struct bcm2835_mmal_dev *dev,
 			 "vid_cap - disconnect previous tunnel\n");
 
 		/* Disconnect any previous connection */
-		vchiq_mmal_port_connect_tunnel(dev->instance,
-					       dev->capture.camera_port, NULL);
+		ret = vchiq_mmal_port_connect_tunnel(dev->instance,
+						     dev->capture.camera_port, NULL);
+		if (ret)
+			return ret;
 		dev->capture.camera_port = NULL;
 		ret = vchiq_mmal_component_disable(dev->instance,
 						   dev->capture.encode_component);