From 26d63d13da2c7de2547f6f455ae20045285dfeb8 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:25 -0300 Subject: [media] exynos4-is: Add locking at fimc(-lite) subdev unregistered handler Protect the fimc/fimc-lite video nodes unregistration with their video lock. This prevents a kernel crash when e.g. udev opens a video node right after the driver registers it and then the driver tries to unregister it and defers its probing. Using video_is_unregistered() together with the video mutex allows safe unregistration of the video nodes at any time. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/media/platform/exynos4-is/fimc-lite.c') diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 24e2a0f8797a..3f76f8abc4b3 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1300,11 +1300,15 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd) if (fimc == NULL) return; + mutex_lock(&fimc->lock); + if (video_is_registered(&fimc->ve.vdev)) { video_unregister_device(&fimc->ve.vdev); media_entity_cleanup(&fimc->ve.vdev.entity); fimc->ve.pipe = NULL; } + + mutex_unlock(&fimc->lock); } static const struct v4l2_subdev_internal_ops fimc_lite_subdev_internal_ops = { -- cgit