[PATCH] staging: vc04_services: Add error handling for vchiq_mmal_port_connect_tunnel

Wentao Liang vulab at iscas.ac.cn
Mon Jan 20 19:19:20 PST 2025


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 at iscas.ac.cn>
---
 .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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);
-- 
2.42.0.windows.2




More information about the linux-rpi-kernel mailing list