]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: v4l2-ctrls: Set error v4l2_ctrl_new_fwnode_properties consistently
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 11 Nov 2025 11:07:29 +0000 (13:07 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 14 Jan 2026 22:33:02 +0000 (23:33 +0100)
The vast majority of the callers of v4l2_ctrl_new_fwnode_properties() do
check the returned error code but the function does not set the control
handler's error on failure. This will make error handling more complicated
and prone for bugs.

Always assign the control handler's error field on error in
v4l2_ctrl_new_fwnode_properties().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/v4l2-core/v4l2-ctrls-core.c
include/media/v4l2-ctrls.h

index 209bc05883bb15bc8614970e7b42595aad6dd18f..1d4b5859f0e26146458cf8c08ea1108806472729 100644 (file)
@@ -2780,7 +2780,8 @@ int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,
                        orientation_ctrl = V4L2_CAMERA_ORIENTATION_EXTERNAL;
                        break;
                default:
-                       return -EINVAL;
+                       hdl->error = -EINVAL;
+                       return hdl->error;
                }
                if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops,
                                            V4L2_CID_CAMERA_ORIENTATION,
index 31fc1bee3797bfe532931889188c8f7a9dedad39..327976b14d50b73a631e4d2ed95d9f4d146c45ab 100644 (file)
@@ -1581,6 +1581,9 @@ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
  * not overwritten. Callers should register the controls they want to handle
  * themselves before calling this function.
  *
+ * This function will set the control handler's error field on failure, just as
+ * other functions adding controls to the handler.
+ *
  * Return: 0 on success, a negative error code on failure.
  */
 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,