aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-02-24 12:58:40 +0000
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-06-27 08:01:49 +0100
commit8ba4862eb59bb2717d8390649cf973a512d892aa (patch)
treef48fa7378ab57b636826fe10b38c72b05ab78b48 /drivers
parentf738cb62a8a7e1bea55e7f7047e2a352f1106f55 (diff)
media: rkisp1: params: Fix and simplify (un)registration
The rkisp1_params_register() and rkisp1_params_unregister() functions don't destroy the mutex (in the error path for the former). Fix this, simplify error handling at registration time as media_entity_cleanup() can be called on an uninitialized entity, and make rkisp1_params_unregister() safe to be called on an unregistered params node to prepare for simplification of error handling at probe time. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/platform/rockchip/rkisp1/rkisp1-params.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
index 8f62f09e635f..f6da2571b55f 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
@@ -1844,16 +1844,20 @@ int rkisp1_params_register(struct rkisp1_device *rkisp1)
node->pad.flags = MEDIA_PAD_FL_SOURCE;
ret = media_entity_pads_init(&vdev->entity, 1, &node->pad);
if (ret)
- return ret;
+ goto error;
+
ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
if (ret) {
dev_err(rkisp1->dev,
"failed to register %s, ret=%d\n", vdev->name, ret);
- goto err_cleanup_media_entity;
+ goto error;
}
+
return 0;
-err_cleanup_media_entity:
+
+error:
media_entity_cleanup(&vdev->entity);
+ mutex_destroy(&node->vlock);
return ret;
}
@@ -1863,6 +1867,10 @@ void rkisp1_params_unregister(struct rkisp1_device *rkisp1)
struct rkisp1_vdev_node *node = &params->vnode;
struct video_device *vdev = &node->vdev;
+ if (!video_is_registered(vdev))
+ return;
+
vb2_video_unregister_device(vdev);
media_entity_cleanup(&vdev->entity);
+ mutex_destroy(&node->vlock);
}

Privacy Policy